[Ada] Spurious error in instance nested in formal package
authorEd Schonberg <schonberg@adacore.com>
Thu, 11 Jun 2020 15:34:26 +0000 (11:34 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 16 Jul 2020 09:18:14 +0000 (05:18 -0400)
gcc/ada/

* sem_ch12.adb (Load_Parent_Of_Generic): If an ancestor is an
instance whose source appears within a formal package of the
current unit, there is no body of the ancestor needed to
complete the current generic compilation.

gcc/ada/sem_ch12.adb

index 4307111f09041e2ff874947be4bbe65140cb288e..b3a4ad4d468332158673519d006c27d79bcfe496 100644 (file)
@@ -14292,6 +14292,21 @@ package body Sem_Ch12 is
 
                exit;
 
+            --  If an ancestor of the generic comes from a formal package
+            --  there is no source for the ancestor body. This is detected
+            --  by examining the scope of the ancestor and its declaration.
+            --  The body, if any is needed, will be available when the
+            --  current unit (containing a formal package) is instantiated.
+
+            elsif Nkind (True_Parent) = N_Package_Specification
+              and then Present (Generic_Parent (True_Parent))
+              and then Nkind
+                (Original_Node (Unit_Declaration_Node
+                  (Scope (Generic_Parent (True_Parent)))))
+                     = N_Formal_Package_Declaration
+            then
+               return;
+
             else
                True_Parent := Parent (True_Parent);
             end if;