https://gcc.gnu.org/bugzilla/show_bug.cgi?id=34511

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Eric Botcazou <[email protected]>:

https://gcc.gnu.org/g:7d9296d0dfbe878598250d176e74b5732b811cff

commit r16-4679-g7d9296d0dfbe878598250d176e74b5732b811cff
Author: Eric Botcazou <[email protected]>
Date:   Tue Oct 28 09:56:33 2025 +0100

    Ada: Fix generic formal subprogram with implicit default wrongly rejected

    It's another issue with a formal subprogram parameter of a generic unit,
    whose default is specified by a box and the actual is omitted, so an
    implicit actual with the name of the formal is used instead and resolved
    in the context of the instance.

    The problem is that, for a child generic unit, the parent unit needs to be
    loaded during the instantiation, but it cannot be used to resolve implicit
    actuals, which must be resolved in the context of the instance.  So an
    ad-hoc mechanism is implemented to prune references to the parent unit(s)
    for this resolution, but that's wrong if the parent unit was loaded at an
    earlier point in the context of the instance.

    The fix disables this ad-hoc mechanism in the case where the parent unit
    has not been loaded during the instantiation by propagating the boolean
    Parent_Installed flag through the call chain.

    gcc/ada/
            PR ada/34511
            * sem_ch12.adb (Analyze_Associations): Add Parent_Installed formal
            parameter and pass it in call to Analyze_One_Association.
            (Analyze_One_Association): Add Parent_Installed formal parameter
            and pass it in call to Instantiate_Formal_Subprogram.
            (Analyze_Formal_Package_Declaration): Pass Parent_Installed in call
            to Analyze_Associations.
            (Analyze_Package_Instantiation): Likewise.
            (Analyze_Subprogram_Instantiation): Likewise.
            (Instantiate_Formal_Subprogram): Add Parent_Installed formal
            parameter and prune references to the parent unit(s) only if
            it is true.

    gcc/testsuite/
            * gnat.dg/specs/generic_inst4-child2.ads: New test.
            * gnat.dg/specs/generic_inst4.ads: New helper.
            * gnat.dg/specs/generic_inst4-child1.ads: Likewise.
  • [Bug ada/34511] generic formal ... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to