From: Bob Duff <[email protected]>

We should not mix "syntactic" and "semantic" for the same field
in different node kinds.

Change the name of Default_Expression (a syntactic field) on
N_Formal_Object_Declaration to be Expression. This avoids
the conflict with the name-named semantic field of
N_Parameter_Specification.

It is also more uniform with other syntactic categories that
use default_expression in the syntax rules.  See, for example,
COMPONENT_DECLARATION in sinfo.ads, which is presumably intended
to be uniform with OBJECT_DECLARATION.

Fix the comment on N_Formal_Object_Declaration to refer
to the new field name Expression.

gcc/ada/ChangeLog:

        * gen_il-gen-gen_nodes.adb: Rename Default_Expression to be
        Expression.
        * gen_il-gen.adb (Check_For_Syntactic_Field_Mismatch): Do not
        exempt Default_Expression from the rule.
        * par-ch12.adb (P_Formal_Object_Declarations): Use renamed setter.
        * sem_ch12.adb (Default): Use renamed getter.
        (Analyze_Formal_Object_Declaration): Likewise.
        * sprint.adb (Sprint_Node_Actual): Use renamed getter.
        * sinfo.ads: Fix comments.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/gen_il-gen-gen_nodes.adb |  2 +-
 gcc/ada/gen_il-gen.adb           |  3 +--
 gcc/ada/par-ch12.adb             |  2 +-
 gcc/ada/sem_ch12.adb             | 12 ++++++------
 gcc/ada/sinfo.ads                |  4 ++--
 gcc/ada/sprint.adb               |  4 ++--
 6 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/gcc/ada/gen_il-gen-gen_nodes.adb b/gcc/ada/gen_il-gen-gen_nodes.adb
index 9fb962bf39c..59fe2d85250 100644
--- a/gcc/ada/gen_il-gen-gen_nodes.adb
+++ b/gcc/ada/gen_il-gen-gen_nodes.adb
@@ -526,7 +526,7 @@ begin -- Gen_IL.Gen.Gen_Nodes
         Sy (Null_Exclusion_Present, Flag, Default_False),
         Sy (Access_Definition, Node_Id, Default_Empty),
         Sy (Subtype_Mark, Node_Id, Default_Empty),
-        Sy (Default_Expression, Node_Id, Default_Empty),
+        Sy (Expression, Node_Id, Default_Empty),
         Sy (Aspect_Specifications, List_Id, Default_No_List),
         Sm (More_Ids, Flag),
         Sm (Prev_Ids, Flag)));
diff --git a/gcc/ada/gen_il-gen.adb b/gcc/ada/gen_il-gen.adb
index 7cf99977dcb..28622ff43d8 100644
--- a/gcc/ada/gen_il-gen.adb
+++ b/gcc/ada/gen_il-gen.adb
@@ -1306,8 +1306,7 @@ package body Gen_IL.Gen is
                   --  for now. At least, we don't want to add any new cases of
                   --  syntactic/semantic mismatch.
 
-                  if F in Actions | Expression | Default_Expression
-                  then
+                  if F in Actions | Expression then
                      pragma Assert (Syntactic_Seen and Semantic_Seen);
 
                   else
diff --git a/gcc/ada/par-ch12.adb b/gcc/ada/par-ch12.adb
index 7bd449d0b72..18cd9072452 100644
--- a/gcc/ada/par-ch12.adb
+++ b/gcc/ada/par-ch12.adb
@@ -466,7 +466,7 @@ package body Ch12 is
          end if;
 
          No_Constraint;
-         Set_Default_Expression (Decl_Node, Init_Expr_Opt);
+         Set_Expression (Decl_Node, Init_Expr_Opt);
          P_Aspect_Specifications (Decl_Node, Semicolon => True);
 
          if Ident > 1 then
diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb
index 8d7378e35b9..cee0b17df46 100644
--- a/gcc/ada/sem_ch12.adb
+++ b/gcc/ada/sem_ch12.adb
@@ -1607,8 +1607,8 @@ package body Sem_Ch12 is
          return Result : Actual_Rec do
             case Nkind (Un_Formal) is
                when N_Formal_Object_Declaration =>
-                  if Present (Default_Expression (Un_Formal)) then
-                     Result := (Name_Exp, Default_Expression (Un_Formal));
+                  if Present (Expression (Un_Formal)) then
+                     Result := (Name_Exp, Expression (Un_Formal));
                   end if;
                when N_Formal_Type_Declaration =>
                   if Present (Default_Subtype_Mark (Un_Formal)) then
@@ -2557,7 +2557,7 @@ package body Sem_Ch12 is
                           (Defining_Identifier
                             (Assoc.Un_Formal), Sloc (N)),
                       Explicit_Generic_Actual_Parameter =>
-                        New_Copy_Tree (Default_Expression (Assoc.Un_Formal))));
+                        New_Copy_Tree (Expression (Assoc.Un_Formal))));
                end if;
             end if;
 
@@ -3361,7 +3361,7 @@ package body Sem_Ch12 is
    ---------------------------------------
 
    procedure Analyze_Formal_Object_Declaration (N : Node_Id) is
-      E  : constant Node_Id := Default_Expression (N);
+      E  : constant Node_Id := Expression (N);
       Id : constant Node_Id := Defining_Identifier (N);
 
       K                : Entity_Kind;
@@ -13239,7 +13239,7 @@ package body Sem_Ch12 is
                end if;
             end;
 
-         elsif Present (Default_Expression (Formal)) then
+         elsif Present (Expression (Formal)) then
 
             --  Use default to construct declaration
 
@@ -13257,7 +13257,7 @@ package body Sem_Ch12 is
                 Null_Exclusion_Present => Null_Exclusion_Present (Formal),
                 Object_Definition      => Def,
                 Expression             => New_Copy_Tree
-                                            (Default_Expression (Formal)));
+                                            (Expression (Formal)));
 
             Copy_Ghost_Aspect (Formal, To => Decl_Node);
             Set_Corresponding_Generic_Association
diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads
index 2c15b80d12e..a1a850adb4a 100644
--- a/gcc/ada/sinfo.ads
+++ b/gcc/ada/sinfo.ads
@@ -5505,7 +5505,7 @@ package Sinfo is
       --  Out_Present
       --  Null_Exclusion_Present
       --  Parameter_Type subtype mark or access definition
-      --  Expression (set to Empty if no default expression present)
+      --  Expression (set to Empty if no default expression)
       --  More_Ids (set to False if no more identifiers in list)
       --  Prev_Ids (set to False if no previous identifiers in list)
       --  Default_Expression
@@ -7236,7 +7236,7 @@ package Sinfo is
       --  Null_Exclusion_Present (set to False if not present)
       --  Subtype_Mark (set to Empty if not present)
       --  Access_Definition (set to Empty if not present)
-      --  Default_Expression (set to Empty if no default expression)
+      --  Expression (set to Empty if no default expression)
       --  More_Ids (set to False if no more identifiers in list)
       --  Prev_Ids (set to False if no previous identifiers in list)
 
diff --git a/gcc/ada/sprint.adb b/gcc/ada/sprint.adb
index f5caa3d1b78..8c49864b87a 100644
--- a/gcc/ada/sprint.adb
+++ b/gcc/ada/sprint.adb
@@ -1963,9 +1963,9 @@ package body Sprint is
                   Sprint_Node (Access_Definition (Node));
                end if;
 
-               if Present (Default_Expression (Node)) then
+               if Present (Expression (Node)) then
                   Write_Str (" := ");
-                  Sprint_Node (Default_Expression (Node));
+                  Sprint_Node (Expression (Node));
                end if;
 
                Write_Char (';');
-- 
2.51.0

Reply via email to