]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Remove Empty_Or_Error
authorBob Duff <duff@adacore.com>
Fri, 30 May 2025 12:07:43 +0000 (08:07 -0400)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 3 Jul 2025 08:16:20 +0000 (10:16 +0200)
Minor stylistic improvement: Remove Empty_Or_Error, and replace
comparisons with Empty_Or_Error with "[not] in Empty | Error".
(Found while working on VAST.)

gcc/ada/ChangeLog:

* types.ads (Empty_Or_Error): Remove.
* atree.adb: Remove reference to Empty_Or_Error.
* par-endh.adb: Likewise.
* sem_ch12.adb: Likewise.
* sem_ch3.adb: Likewise.
* sem_util.adb: Likewise.
* treepr.adb: Likewise.

gcc/ada/atree.adb
gcc/ada/par-endh.adb
gcc/ada/sem_ch12.adb
gcc/ada/sem_ch3.adb
gcc/ada/sem_util.adb
gcc/ada/treepr.adb
gcc/ada/types.ads

index 17538de8954dcb9a9284024402ec21e1b1531074..20ca189ad8c34b9d56bbab3e2c096a1ac2e870a8 100644 (file)
@@ -1296,8 +1296,7 @@ package body Atree is
         Node_Offsets.Table (Node_Offsets.First .. Node_Offsets.Last);
 
    begin
-      --  Empty_Or_Error use as described in types.ads
-      if Destination <= Empty_Or_Error or No (Source) then
+      if Destination in Empty | Error or else No (Source) then
          pragma Assert (Serious_Errors_Detected > 0);
          return;
       end if;
@@ -1458,7 +1457,7 @@ package body Atree is
    --  Start of processing for Copy_Separate_Tree
 
    begin
-      if Source <= Empty_Or_Error then
+      if Source in Empty | Error then
          return Source;
 
       elsif Is_Entity (Source) then
@@ -1841,7 +1840,7 @@ package body Atree is
       pragma Debug (Validate_Node (Source));
       S_Size : constant Slot_Count := Size_In_Slots_To_Alloc (Source);
    begin
-      if Source <= Empty_Or_Error then
+      if Source in Empty | Error then
          return Source;
       end if;
 
index 12baed455d7f61c84d1c3b6137425426eb41784e..b045d74bd0eef5d1a123c003cc005eb0f384cf1e 100644 (file)
@@ -300,7 +300,7 @@ package body Endh is
             else
                End_Labl := Scopes (Scope.Last).Labl;
 
-               if End_Labl > Empty_Or_Error then
+               if End_Labl not in Empty | Error then
 
                   --  The task here is to construct a designator from the
                   --  opening label, with the components all marked as not
@@ -921,7 +921,7 @@ package body Endh is
 
       --  Suppress message if error was posted on opening label
 
-      if Error_Msg_Node_1 > Empty_Or_Error
+      if Error_Msg_Node_1 not in Empty | Error
         and then Error_Posted (Error_Msg_Node_1)
       then
          return;
index f492b236857553b9d84e639a87a0815573ac92f3..7ebf145d783e93789e248815718e1d48e9ddc5bc 100644 (file)
@@ -3171,7 +3171,7 @@ package body Sem_Ch12 is
          end if;
       end if;
 
-      if Subtype_Mark (Def) <= Empty_Or_Error then
+      if Subtype_Mark (Def) in Empty | Error then
          pragma Assert (Serious_Errors_Detected > 0);
          --  avoid passing bad argument to Entity
          return;
index 45b28bf96a4b65f750e4914a381db826c9976b73..b4342af134e6041ae2b43b81e8c32e2ba7e261a7 100644 (file)
@@ -19159,8 +19159,7 @@ package body Sem_Ch3 is
       --  Otherwise we have a subtype mark without a constraint
 
       elsif Error_Posted (S) then
-         --  Don't rewrite if S is Empty or Error
-         if S > Empty_Or_Error then
+         if S not in Empty | Error then
             Rewrite (S, New_Occurrence_Of (Any_Id, Sloc (S)));
          end if;
          return Any_Type;
@@ -21094,7 +21093,7 @@ package body Sem_Ch3 is
 
       --  If no range was given, set a dummy range
 
-      if RRS <= Empty_Or_Error then
+      if RRS in Empty | Error then
          Low_Val  := -Small_Val;
          High_Val := Small_Val;
 
index b61f3bbad5e12286edee8cd19571ab12ecc41d31..ed8f054fc6345b98048b979ceabc7556128fe68a 100644 (file)
@@ -24112,7 +24112,7 @@ package body Sem_Util is
 
          Result := N;
 
-         if N > Empty_Or_Error then
+         if N not in Empty | Error then
             pragma Assert (Nkind (N) not in N_Entity);
 
             Result := New_Copy (N);
@@ -24193,7 +24193,7 @@ package body Sem_Util is
 
          Result := Id;
 
-         if Id > Empty_Or_Error then
+         if Id not in Empty | Error then
             pragma Assert (Nkind (Id) in N_Entity);
 
             --  Determine whether the entity has a corresponding new entity
index d58f3ceb36fb520726e00394701a1a917479e328..375608d2ba66c5f40a745b71dbb869a81d8d4ec3 100644 (file)
@@ -2015,17 +2015,16 @@ package body Treepr is
          --  Case of descendant is a node
 
          if D in Node_Range then
-
-            --  Don't bother about Empty or Error descendants
-
-            if D <= Union_Id (Empty_Or_Error) then
-               return;
-            end if;
-
             declare
                Nod : constant Node_Or_Entity_Id := Node_Or_Entity_Id (D);
 
             begin
+               --  Don't bother about Empty or Error descendants
+
+               if Nod in Empty | Error then
+                  return;
+               end if;
+
                --  Descendants in one of the standardly compiled internal
                --  packages are normally ignored, unless the parent is also
                --  in such a package (happens when Standard itself is output)
index 8869d0120f90efbb02a6e80a9f3f43226c93f2a0..6258ff90ba1edcd33b83cd77de8808d82715be7a 100644 (file)
@@ -431,11 +431,6 @@ package Types is
    --  Used to indicate an error in the source program. A node is actually
    --  allocated with this Id value, so that Nkind (Error) = N_Error.
 
-   Empty_Or_Error : constant Node_Id := Error;
-   --  Since Empty and Error are the first two Node_Id values, the test for
-   --  N <= Empty_Or_Error tests to see if N is Empty or Error. This definition
-   --  provides convenient self-documentation for such tests.
-
    First_Node_Id  : constant Node_Id := Node_Low_Bound;
    --  Subscript of first allocated node. Note that Empty and Error are both
    --  allocated nodes, whose Nkind fields can be accessed without error.