]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Get rid of Sy/Sm mixing (Actions)
authorBob Duff <duff@adacore.com>
Fri, 10 Oct 2025 16:40:42 +0000 (12:40 -0400)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Mon, 3 Nov 2025 14:15:16 +0000 (15:15 +0100)
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.

gcc/ada/gen_il-gen-gen_nodes.adb
gcc/ada/gen_il-gen.adb
gcc/ada/sinfo.ads

index 844faf3873b668c5aa9a4bb0e8d29f6ceafdd705..e123631bb013ab8ede0337fce1ac43342dd0abfd 100644 (file)
@@ -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,
index 9a441f228e3fced31d31f9381f7a4436e3483205..26d0193702ccd510c01c4a23410da5b5d71a420d 100644 (file)
@@ -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
index 54a3d9b3416e87ae6a0bed7c2492c2a6a07aa349..f6610b74e03ed76b56d1a78fc718550be400a694 100644 (file)
@@ -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 --
       --------------