diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2022-12-22 12:14:08 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-05-15 11:36:40 +0200 |
commit | 983f4eff259317f4c3d0a5a3726bb1c8dcd9a623 (patch) | |
tree | b0f409c847d01624be87a1e3f600eb11cf69cef6 | |
parent | bc60b3c350885cf60547f9e7002248b9bbb81e3d (diff) | |
download | gcc-983f4eff259317f4c3d0a5a3726bb1c8dcd9a623.zip gcc-983f4eff259317f4c3d0a5a3726bb1c8dcd9a623.tar.gz gcc-983f4eff259317f4c3d0a5a3726bb1c8dcd9a623.tar.bz2 |
ada: Reject attribute Initialize on unchecked unions
Attribute Initialized is expanded into Valid_Scalars, which can't work
on unchecked unions, so Initialized on unchecked unions needs to be
rejected before expansion.
gcc/ada/
* sem_attr.adb (Analyze_Attribute): Reject attribute Initialized
on unchecked unions; fix grammar in comment.
-rw-r--r-- | gcc/ada/sem_attr.adb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index a9e64b7..77c56aa 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -4613,7 +4613,7 @@ package body Sem_Attr is if Comes_From_Source (N) then - -- This attribute be prefixed with references to objects or + -- This attribute can be prefixed with references to objects or -- values (such as a current instance value given within a type -- or subtype aspect). @@ -4621,6 +4621,13 @@ package body Sem_Attr is and then not Is_Current_Instance_Reference_In_Type_Aspect (P) then Error_Attr_P ("prefix of % attribute must be object"); + + -- Just like attribute 'Valid_Scalars this attribute is illegal + -- on unchecked union types. + + elsif Has_Unchecked_Union (Validated_View (P_Type)) then + Error_Attr_P + ("attribute % not allowed for Unchecked_Union type"); end if; end if; |