]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Set syntactic node properties immediately when crating the nodes
authorPiotr Trojanek <trojanek@adacore.com>
Mon, 23 Dec 2024 09:05:47 +0000 (10:05 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 10 Jan 2025 09:39:56 +0000 (10:39 +0100)
When creating a node, we can directly set its syntactic properties.
Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* contracts.adb (Build_Call_Helper_Decl): Tune whitespace.
* exp_attr.adb (Analyze_Attribute): Set Of_Present while
creating the node; reorder setting Subtype_Indication to match the
syntax order.
* exp_ch3.adb (Build_Equivalent_Aggregate): Likewise for Box_Present
and Expression properties.
* sem_ch12.adb (Analyze_Formal_Derived_Type): Set type properties
when creating the nodes.
* sem_ch3.adb (Check_Anonymous_Access_Component): Likewise.

gcc/ada/contracts.adb
gcc/ada/exp_attr.adb
gcc/ada/exp_ch3.adb
gcc/ada/sem_ch12.adb
gcc/ada/sem_ch3.adb

index 1c9161b8a37e13e9f03e8b8ec7d051e3a438020b..8b94a67639f2e0599e47bdcbfbb765908b4d6157 100644 (file)
@@ -4066,8 +4066,8 @@ package body Contracts is
 
          begin
             Spec := Build_Call_Helper_Spec (Helper_Id);
-            Set_Must_Override      (Spec, False);
-            Set_Must_Not_Override  (Spec, False);
+            Set_Must_Override     (Spec, False);
+            Set_Must_Not_Override (Spec, False);
             Set_Is_Inlined (Helper_Id);
             Set_Is_Public  (Helper_Id);
 
index cc42d64706012c58881c98aed7c1d7ae36288532..b896228a70e39a79e2697ba93eedfe8440fe3c91 100644 (file)
@@ -6422,10 +6422,10 @@ package body Exp_Attr is
                begin
                   Iter :=
                     Make_Iterator_Specification (Loc,
-                    Defining_Identifier => Elem,
-                    Name => Relocate_Node (Prefix (N)),
-                    Subtype_Indication => Empty);
-                  Set_Of_Present (Iter);
+                      Defining_Identifier => Elem,
+                      Subtype_Indication  => Empty,
+                      Of_Present          => True,
+                      Name                => Relocate_Node (Prefix (N)));
 
                   New_Loop := Make_Loop_Statement (Loc,
                     Iteration_Scheme =>
index d95b917803064e2f671a52b5040f9bd78f19e804..0dfd8102df18eedeaaf5d24a830e6ace9791761c 100644 (file)
@@ -1349,9 +1349,8 @@ package body Exp_Ch3 is
 
          Append_To (Component_Associations (Aggr),
            Make_Component_Association (Loc,
-             Choices    => New_List (Make_Others_Choice (Loc)),
-             Expression => Empty));
-         Set_Box_Present (Last (Component_Associations (Aggr)));
+             Choices     => New_List (Make_Others_Choice (Loc)),
+             Box_Present => True));
 
          if Typ /= Full_Typ then
             Analyze_And_Resolve (Aggr, Full_View (Base_Type (Full_Typ)));
index 088a9ccfb58962ac8c0627601049e7fb8d25620d..dad8c73729e90f4b989b20644acc4b9b49be76d1 100644 (file)
@@ -3097,13 +3097,11 @@ package body Sem_Ch12 is
              Defining_Identifier           => T,
              Discriminant_Specifications   => Discriminant_Specifications (N),
              Unknown_Discriminants_Present => Unk_Disc,
+             Abstract_Present              => Abstract_Present (Def),
+             Limited_Present               => Limited_Present (Def),
              Subtype_Indication            => Subtype_Mark (Def),
+             Synchronized_Present          => Synchronized_Present (Def),
              Interface_List                => Interface_List (Def));
-
-         Set_Abstract_Present     (New_N, Abstract_Present     (Def));
-         Set_Limited_Present      (New_N, Limited_Present      (Def));
-         Set_Synchronized_Present (New_N, Synchronized_Present (Def));
-
       else
          New_N :=
            Make_Full_Type_Declaration (Loc,
@@ -3112,12 +3110,9 @@ package body Sem_Ch12 is
                Discriminant_Specifications (Parent (T)),
              Type_Definition             =>
                Make_Derived_Type_Definition (Loc,
+                 Abstract_Present   => Abstract_Present (Def),
+                 Limited_Present    => Limited_Present (Def),
                  Subtype_Indication => Subtype_Mark (Def)));
-
-         Set_Abstract_Present
-           (Type_Definition (New_N), Abstract_Present (Def));
-         Set_Limited_Present
-           (Type_Definition (New_N), Limited_Present  (Def));
       end if;
 
       Rewrite (N, New_N);
index cf6ab68d4e61824d0d9637a810208cc4320ccb73..64e3f85c605f15d3520359a42991631b6a53dc16 100644 (file)
@@ -1409,10 +1409,10 @@ package body Sem_Ch3 is
                begin
                   Decl :=
                     Make_Subtype_Declaration (Loc,
-                      Defining_Identifier => Nam,
-                      Subtype_Indication  =>
+                      Defining_Identifier    => Nam,
+                      Null_Exclusion_Present => True,
+                      Subtype_Indication     =>
                         New_Occurrence_Of (Entity (S), Loc));
-                  Set_Null_Exclusion_Present (Decl);
                   Insert_Before (Parent (Def), Decl);
                   Analyze (Decl);
                   Set_Entity (S, Nam);
@@ -12191,11 +12191,10 @@ package body Sem_Ch3 is
          else
             Type_Def :=
               Make_Access_To_Object_Definition (Loc,
+                All_Present        => All_Present (Access_Def),
+                Constant_Present   => Constant_Present (Access_Def),
                 Subtype_Indication =>
-                   Relocate_Node (Subtype_Mark (Access_Def)));
-
-            Set_Constant_Present (Type_Def, Constant_Present (Access_Def));
-            Set_All_Present (Type_Def, All_Present (Access_Def));
+                  Relocate_Node (Subtype_Mark (Access_Def)));
          end if;
 
          Set_Null_Exclusion_Present