diff mbox series

[Ada] Simplify traversal for removing warnings from dead code

Message ID 20220106171315.GA2921814@adacore.com
State New
Headers show
Series [Ada] Simplify traversal for removing warnings from dead code | expand

Commit Message

Pierre-Marie de Rodat Jan. 6, 2022, 5:13 p.m. UTC
Cleanup related to handling of warnings-as-errors. Semantics is
unaffected.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* errout.adb (Remove_Warning_Messages): Use traversal procedure
	instead of traversal function, since we discard status of each
	step anyway.
diff mbox series

Patch

diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb
--- a/gcc/ada/errout.adb
+++ b/gcc/ada/errout.adb
@@ -3254,7 +3254,7 @@  package body Errout is
       function Check_For_Warning (N : Node_Id) return Traverse_Result;
       --  This function checks one node for a possible warning message
 
-      function Check_All_Warnings is new Traverse_Func (Check_For_Warning);
+      procedure Check_All_Warnings is new Traverse_Proc (Check_For_Warning);
       --  This defines the traversal operation
 
       -----------------------
@@ -3341,37 +3341,23 @@  package body Errout is
             --  the current tree. Given that we are in unreachable code, this
             --  modification to the tree is harmless.
 
-            declare
-               Status : Traverse_Final_Result;
-
-            begin
-               if Is_List_Member (N) then
-                  Set_Condition (N, Original_Node (N));
-                  Status := Check_All_Warnings (Condition (N));
-               else
-                  Rewrite (N, Original_Node (N));
-                  Status := Check_All_Warnings (N);
-               end if;
-
-               return Status;
-            end;
-
-         else
-            return OK;
+            if Is_List_Member (N) then
+               Set_Condition (N, Original_Node (N));
+               Check_All_Warnings (Condition (N));
+            else
+               Rewrite (N, Original_Node (N));
+               Check_All_Warnings (N);
+            end if;
          end if;
+
+         return OK;
       end Check_For_Warning;
 
    --  Start of processing for Remove_Warning_Messages
 
    begin
       if Warnings_Detected /= 0 then
-         declare
-            Discard : Traverse_Final_Result;
-            pragma Warnings (Off, Discard);
-
-         begin
-            Discard := Check_All_Warnings (N);
-         end;
+         Check_All_Warnings (N);
       end if;
    end Remove_Warning_Messages;