From d2bc32602c58f14cddc8634fe36141137e2861d1 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Wed, 8 Dec 2021 16:00:05 +0100 Subject: [PATCH] [Ada] Simplify traversal for removing warnings from dead code 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 | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/gcc/ada/errout.adb b/gcc/ada/errout.adb index 8bfbe46..b40a8bb 100644 --- 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; -- 2.7.4