diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2025-03-17 13:20:53 +0100 |
---|---|---|
committer | Eric Botcazou <ebotcazou@adacore.com> | 2025-06-09 10:23:59 +0200 |
commit | 6cc5c01aa77a1f01057a963cc5061bad4b0cc270 (patch) | |
tree | 8777282f23c8897c2160287e999dd2d02dcd8588 /gcc | |
parent | 2fd267be72dfb0dbaa422c21888a40e69173defa (diff) | |
download | gcc-6cc5c01aa77a1f01057a963cc5061bad4b0cc270.zip gcc-6cc5c01aa77a1f01057a963cc5061bad4b0cc270.tar.gz gcc-6cc5c01aa77a1f01057a963cc5061bad4b0cc270.tar.bz2 |
ada: Reject component-related aspects on formal non-array types
In Ada 2022 aspects Atomic_Components and Volatile_Components can be specified
for a formal array type, but they were wrongly accepted on any formal type.
Also, we don't need to check if the corresponding pragmas appear in Ada 2022
mode, because generic formal parameters can't have explicit representation
pragmas in any Ada version and can only have aspects since Ada 2022.
gcc/ada/ChangeLog:
* sem_prag.adb (Analyze_Pragma): Fix conditions for legality checks on
formal type declarations.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sem_prag.adb | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 17805c9..19e72ab 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -14696,21 +14696,18 @@ package body Sem_Prag is D := Declaration_Node (E); - if (Nkind (D) = N_Full_Type_Declaration and then Is_Array_Type (E)) + if (Nkind (D) in N_Full_Type_Declaration + | N_Formal_Type_Declaration + and then Is_Array_Type (E)) or else (Nkind (D) = N_Object_Declaration and then Ekind (E) in E_Constant | E_Variable and then Nkind (Object_Definition (D)) = N_Constrained_Array_Definition) - or else - (Ada_Version >= Ada_2022 - and then Nkind (D) = N_Formal_Type_Declaration) then -- The flag is set on the base type, or on the object - if Nkind (D) in N_Full_Type_Declaration - | N_Formal_Type_Declaration - then + if Is_Array_Type (E) then E := Base_Type (E); end if; |