From: Bob Duff <[email protected]>
We should not mix "syntactic" and "semantic" for the same field
in different node kinds.
The Actions field is both syntactic and semantic. This patch
makes it always syntactic.
No change in overall compiler behavior.
gcc/ada/ChangeLog:
* gen_il-gen.adb (N_Short_Circuit):
Make Actions syntactic.
(N_Case_Expression_Alternative): Likewise.
* gen_il-gen-gen_nodes.adb (Create_Type):
No longer exempt Actions from the syntactic/semantic ordering rule.
(Check_For_Syntactic_Field_Mismatch):
No longer exempt Actions from the syntactic/semantic mixing rule.
* sinfo.ads (N_Compound_Statement):
Add comment.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/gen_il-gen-gen_nodes.adb | 6 +++---
gcc/ada/gen_il-gen.adb | 19 ++++++++-----------
gcc/ada/sinfo.ads | 3 +++
3 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/gcc/ada/gen_il-gen-gen_nodes.adb b/gcc/ada/gen_il-gen-gen_nodes.adb
index 844faf3873b..e123631bb01 100644
--- a/gcc/ada/gen_il-gen-gen_nodes.adb
+++ b/gcc/ada/gen_il-gen-gen_nodes.adb
@@ -301,7 +301,7 @@ begin -- Gen_IL.Gen.Gen_Nodes
Ab (N_Short_Circuit, N_Subexpr,
(Sy (Left_Opnd, Node_Id),
Sy (Right_Opnd, Node_Id),
- Sm (Actions, List_Id)));
+ Sy (Actions, List_Id, Default_No_List)));
Cc (N_And_Then, N_Short_Circuit);
Cc (N_Or_Else, N_Short_Circuit);
@@ -1161,9 +1161,9 @@ begin -- Gen_IL.Gen.Gen_Nodes
Sm (Target, Node_Id)));
Cc (N_Case_Expression_Alternative, Node_Kind,
- (Sm (Actions, List_Id),
- Sy (Discrete_Choices, List_Id),
+ (Sy (Discrete_Choices, List_Id),
Sy (Expression, Node_Id, Default_Empty),
+ Sy (Actions, List_Id, Default_No_List),
Sm (Has_SP_Choice, Flag)));
Cc (N_Case_Statement_Alternative, Node_Kind,
diff --git a/gcc/ada/gen_il-gen.adb b/gcc/ada/gen_il-gen.adb
index 9a441f228e3..26d0193702c 100644
--- a/gcc/ada/gen_il-gen.adb
+++ b/gcc/ada/gen_il-gen.adb
@@ -167,7 +167,6 @@ package body Gen_IL.Gen is
-- Check that syntactic fields precede semantic fields. Note that this
-- check is happening before we compute inherited fields.
- -- Exempt Actions from this rule, for now.
declare
Semantic_Seen : Boolean := False;
@@ -178,11 +177,8 @@ package body Gen_IL.Gen is
raise Illegal with
"syntactic fields must precede semantic ones " & Image (T);
end if;
-
else
- if Fields (J).F /= Actions then
- Semantic_Seen := True;
- end if;
+ Semantic_Seen := True;
end if;
end loop;
end;
@@ -509,7 +505,7 @@ package body Gen_IL.Gen is
Node_Field_Types_Used, Entity_Field_Types_Used : Type_Set;
Setter_Needs_Parent : Field_Set :=
- (Actions | Expression | Then_Actions | Else_Actions => True,
+ (Expression | Then_Actions | Else_Actions => True,
others => False);
-- Set of fields where the setter should set the Parent. True for
-- syntactic fields of type Node_Id and List_Id, but with some
@@ -1300,12 +1296,13 @@ package body Gen_IL.Gen is
end if;
end loop;
- -- The following fields violate this rule. We might want to
- -- simplify by getting rid of these cases, but we allow them
- -- for now. At least, we don't want to add any new cases of
- -- syntactic/semantic mismatch.
+ -- ???The following fields violate this rule. We might want
+ -- to simplify by getting rid of these cases, but we allow
+ -- them for now. At least, we don't want to add any new
+ -- cases of syntactic/semantic mismatch.
+ -- ???Just one case left.
- if F in Actions | Expression then
+ if F in Expression then
pragma Assert (Syntactic_Seen and Semantic_Seen);
else
diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads
index 54a3d9b3416..f6610b74e03 100644
--- a/gcc/ada/sinfo.ads
+++ b/gcc/ada/sinfo.ads
@@ -7938,6 +7938,9 @@ package Sinfo is
-- N_Compound_Statement
-- Actions
+ -- Note that N_Compound_Statement is unrelated to the Ada syntax rule
+ -- for compound_statement.
+
--------------
-- Contract --
--------------
--
2.51.0