]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix glitch in handling of Atomic_Components on generic formal type
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 17 Mar 2025 11:57:26 +0000 (12:57 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 9 Jun 2025 06:32:13 +0000 (08:32 +0200)
In Ada 2022 aspects Atomic_Components and Volatile_Components can be specified
for a formal array type, but then they need to be set on the base type entity.
Otherwise we get an assertion failure in debug build and wrong legality errors
in production builds.

gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Pragma): If pragmas apply to a formal array
type, then set the flags on the base type.

gcc/ada/sem_prag.adb

index 4090d0c71175897c6f6e0d46ce2667715ea45aa4..01983f9d89fd8eac3ac4c801c63f2b99d79afe2c 100644 (file)
@@ -14689,7 +14689,9 @@ package body Sem_Prag is
             then
                --  The flag is set on the base type, or on the object
 
-               if Nkind (D) = N_Full_Type_Declaration then
+               if Nkind (D) in N_Full_Type_Declaration
+                             | N_Formal_Type_Declaration
+               then
                   E := Base_Type (E);
                end if;