https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123580
--- Comment #9 from Eric Botcazou <ebotcazou at gcc dot gnu.org> --- https://gcc.gnu.org/g:89f58d2df5cf124ac2b8c574911bb53b0db7f466 commit r16-6953-g89f58d2df5cf124ac2b8c574911bb53b0db7f466 Author: Eric Botcazou <[email protected]> Date: Wed Jan 21 11:47:42 2026 +0100 Ada: Fix visibility issue on generic parent from nested generic package The problem is that we temporarily push onto the scope stack and install the declarations of a package that is already on the scope stack and whose declarations are already visible so, when the temporary condition is over, the declarations are uninstalled, thus making them definitively invisible. It comes from the use of the idiom Scope_Within_Or_Same (Current_Scope, S) to detect whether S is open in the current scope, but that's not robust in the presence of transient scopes or during instantiation of generic units. gcc/ada/ PR ada/123580 * sem_ch13.adb (Analyze_Aspects_At_Freeze_Point): Replace call to Scope_Within_Or_Same (Current_Scope, S) with In_Open_Scopes (S) to test whether S is open in the current scope. * sem_util.adb (From_Nested_Package): Likewise. gcc/testsuite/ * gnat.dg/generic_inst16.adb: New test. * gnat.dg/generic_inst16_pkg.ads: New helper. * gnat.dg/generic_inst16_pkg-child.ads: Likewise. * gnat.dg/generic_inst16_pkg-child-grandchild.ads: Likewise. * gnat.dg/generic_inst16_proc.ads: Likewise. * gnat.dg/generic_inst16_proc.adb: Likewise.
