From: Bob Duff <d...@adacore.com> 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. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/atree.adb | 7 +++---- gcc/ada/par-endh.adb | 4 ++-- gcc/ada/sem_ch12.adb | 2 +- gcc/ada/sem_ch3.adb | 5 ++--- gcc/ada/sem_util.adb | 4 ++-- gcc/ada/treepr.adb | 13 ++++++------- gcc/ada/types.ads | 5 ----- 7 files changed, 16 insertions(+), 24 deletions(-) diff --git a/gcc/ada/atree.adb b/gcc/ada/atree.adb index 17538de8954..20ca189ad8c 100644 --- a/gcc/ada/atree.adb +++ b/gcc/ada/atree.adb @@ -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; diff --git a/gcc/ada/par-endh.adb b/gcc/ada/par-endh.adb index 12baed455d7..b045d74bd0e 100644 --- a/gcc/ada/par-endh.adb +++ b/gcc/ada/par-endh.adb @@ -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; diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index f492b236857..7ebf145d783 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -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; diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb index 45b28bf96a4..b4342af134e 100644 --- a/gcc/ada/sem_ch3.adb +++ b/gcc/ada/sem_ch3.adb @@ -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; diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index b61f3bbad5e..ed8f054fc63 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -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 diff --git a/gcc/ada/treepr.adb b/gcc/ada/treepr.adb index d58f3ceb36f..375608d2ba6 100644 --- a/gcc/ada/treepr.adb +++ b/gcc/ada/treepr.adb @@ -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) diff --git a/gcc/ada/types.ads b/gcc/ada/types.ads index 8869d0120f9..6258ff90ba1 100644 --- a/gcc/ada/types.ads +++ b/gcc/ada/types.ads @@ -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. -- 2.43.0