]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix handling of Global contracts inside generic subprograms
authorPiotr Trojanek <trojanek@adacore.com>
Tue, 5 Oct 2021 13:29:44 +0000 (15:29 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 26 May 2023 07:29:17 +0000 (09:29 +0200)
Routine Get_Argument works differently for generic units (as explained
in its comment), but it failed to reliably detect such units when their
kind is temporarily made non-generic (for resolving recursive calls, as
explained in the comment at the end of Is_Generic_Declaration_Or_Body).

With this patch the frontend will look at the decorated expression of
the Global contract attached to the Global aspect; previously it was
looking at the undecorated expression attached to the corresponding
pragma.

gcc/ada/

* sem_prag.adb (Get_Argument): Improve detection of generic units.

gcc/ada/sem_prag.adb

index d66e5612135b43ac4a7cc96ace6569b4133b85cf..96ea17209f34845db446b221f1e1cea27f5039a2 100644 (file)
@@ -31650,7 +31650,9 @@ package body Sem_Prag is
       --  to save the global references in the generic context.
 
       if From_Aspect_Specification (Prag)
-        and then (Present (Context_Id) and then Is_Generic_Unit (Context_Id))
+        and then Present (Context_Id)
+        and then
+          Is_Generic_Declaration_Or_Body (Unit_Declaration_Node (Context_Id))
       then
          return Corresponding_Aspect (Prag);