diff options
author | Ghjuvan Lacambre <lacambre@adacore.com> | 2020-05-11 13:51:13 +0200 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-07-07 05:26:55 -0400 |
commit | d4175ef48ba562f6fb8098b6fa000f3d77e11e1b (patch) | |
tree | c2d4d1476bf72c6c8897fcb3884925e1dcde0eb3 | |
parent | 58e07eaae447b73763ae390a13a613a6b70679ce (diff) | |
download | gcc-d4175ef48ba562f6fb8098b6fa000f3d77e11e1b.zip gcc-d4175ef48ba562f6fb8098b6fa000f3d77e11e1b.tar.gz gcc-d4175ef48ba562f6fb8098b6fa000f3d77e11e1b.tar.bz2 |
[Ada] Ensure No_Specification_Of_Aspect forbids pragmas and repr. clauses
gcc/ada/
* sem_ch13.adb (Analyze_Attribute_Definition_Clause): Add call
to Check_Restriction_No_Specification_Of_Aspect.
* sem_prag.adb (Analyze_Pragma): Likewise.
* restrict.ads (Check_Restriction_No_Specification_Of_Aspect):
Mention possible new node kinds in documentation.
* restrict.adb (Check_Restriction_No_Specification_Of_Aspect):
Retrieve aspect id from different fields if given node is an
N_Pragma or an N_Attribute_Definition_Clause.
-rw-r--r-- | gcc/ada/restrict.adb | 9 | ||||
-rw-r--r-- | gcc/ada/restrict.ads | 7 | ||||
-rw-r--r-- | gcc/ada/sem_ch13.adb | 7 | ||||
-rw-r--r-- | gcc/ada/sem_prag.adb | 7 |
4 files changed, 26 insertions, 4 deletions
diff --git a/gcc/ada/restrict.adb b/gcc/ada/restrict.adb index 0dab4c5..08788d1 100644 --- a/gcc/ada/restrict.adb +++ b/gcc/ada/restrict.adb @@ -626,7 +626,14 @@ package body Restrict is return; end if; - Id := Identifier (N); + if Nkind (N) = N_Pragma then + Id := Pragma_Identifier (N); + elsif Nkind (N) = N_Attribute_Definition_Clause then + Id := N; + else + Id := Identifier (N); + end if; + A_Id := Get_Aspect_Id (Chars (Id)); pragma Assert (A_Id /= No_Aspect); diff --git a/gcc/ada/restrict.ads b/gcc/ada/restrict.ads index bcea115..a638401 100644 --- a/gcc/ada/restrict.ads +++ b/gcc/ada/restrict.ads @@ -283,9 +283,10 @@ package Restrict is -- the node to which an error will be attached if necessary. procedure Check_Restriction_No_Specification_Of_Aspect (N : Node_Id); - -- N is the node id for an N_Aspect_Specification. An error message - -- (warning) will be issued if a restriction (warning) was previously set - -- for this aspect using Set_No_Specification_Of_Aspect. + -- N is the node id for an N_Aspect_Specification, an N_Pragma, or an + -- N_Attribute_Definition_Clause. An error message (warning) will be issued + -- if a restriction (warning) was previously set for this aspect using + -- Set_No_Specification_Of_Aspect. procedure Check_Restriction_No_Use_Of_Attribute (N : Node_Id); -- N denotes an attribute definition clause or an attribute reference. An diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index e73cf94..f854711 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -5643,6 +5643,13 @@ package body Sem_Ch13 is Check_Restriction_No_Use_Of_Attribute (N); + if Get_Aspect_Id (Chars (N)) /= No_Aspect then + -- 6.1/3 No_Specification_of_Aspect: Identifies an aspect for which + -- no aspect_specification, attribute_definition_clause, or pragma + -- is given. + Check_Restriction_No_Specification_Of_Aspect (N); + end if; + -- Ignore some selected attributes in CodePeer mode since they are not -- relevant in this context. diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index b3d128b..95a1173 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -11477,6 +11477,13 @@ package body Sem_Prag is Check_Restriction_No_Use_Of_Pragma (N); + if Get_Aspect_Id (Chars (Pragma_Identifier (N))) /= No_Aspect then + -- 6.1/3 No_Specification_of_Aspect: Identifies an aspect for which + -- no aspect_specification, attribute_definition_clause, or pragma + -- is given. + Check_Restriction_No_Specification_Of_Aspect (N); + end if; + -- Ignore pragma if Ignore_Pragma applies. Also ignore pragma -- Default_Scalar_Storage_Order if the -gnatI switch was given. |