sem_ch12.adb (Copy_Generic_Node): A reference to a child unit of the generic for...
authorEd Schonberg <schonberg@adacore.com>
Thu, 16 Aug 2007 12:20:00 +0000 (14:20 +0200)
committerArnaud Charlet <charlet@gcc.gnu.org>
Thu, 16 Aug 2007 12:20:00 +0000 (14:20 +0200)
2007-08-16  Ed Schonberg  <schonberg@adacore.com>

* sem_ch12.adb (Copy_Generic_Node): A reference to a child unit of the
generic for an enclosing instance is a global reference, even though
its scope is the enclosing instance.

From-SVN: r127546

gcc/ada/sem_ch12.adb

index fc649dc625d34f8d19cbda50d064eb071fec6658..f48724db19dc3eff43224fef00a99bfb350abd16 100644 (file)
@@ -5628,6 +5628,8 @@ package body Sem_Ch12 is
             --  reset the entity in the generic copy. A global reference has a
             --  smaller depth than the parent, or else the same depth in case
             --  both are distinct compilation units.
+            --  A child unit is implicitly declared within the enclosing parent
+            --  but is in fact global to it, and must be preserved.
 
             --  It is also possible for Current_Instantiated_Parent to be
             --  defined, and for this not to be a nested generic, namely if the
@@ -5658,7 +5660,9 @@ package body Sem_Ch12 is
                        or else
                      Nkind (Ent) = N_Defining_Operator_Symbol)
               or else No (Scope (Ent))
-              or else Scope (Ent) = Current_Instantiated_Parent.Gen_Id
+              or else
+                (Scope (Ent) = Current_Instantiated_Parent.Gen_Id
+                  and then not Is_Child_Unit (Ent))
               or else (Scope_Depth (Scope (Ent)) >
                              Scope_Depth (Current_Instantiated_Parent.Gen_Id)
                          and then