]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Simplify traversal for removing warnings from dead code
authorPiotr Trojanek <trojanek@adacore.com>
Wed, 8 Dec 2021 15:00:05 +0000 (16:00 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 6 Jan 2022 17:11:41 +0000 (17:11 +0000)
gcc/ada/

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

gcc/ada/errout.adb

index 8bfbe46315abbc4a12779ee352813a1a1b00fed7..b40a8bb1e01b6c80d321958c6b00df19dedc03c6 100644 (file)
@@ -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;