From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id F035538515C2; Wed, 13 Jul 2022 10:02:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F035538515C2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-1656] [Ada] Fix CodePeer warnings in GNAT sources X-Act-Checkin: gcc X-Git-Author: Justin Squirek X-Git-Refname: refs/heads/master X-Git-Oldrev: 1d73dfb5e6f60030bb0809266fb9c639eb60fa11 X-Git-Newrev: 730814edc8b3c1bc872c54a39064ac59e2b8fdbd Message-Id: <20220713100245.F035538515C2@sourceware.org> Date: Wed, 13 Jul 2022 10:02:45 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2022 10:02:46 -0000 https://gcc.gnu.org/g:730814edc8b3c1bc872c54a39064ac59e2b8fdbd commit r13-1656-g730814edc8b3c1bc872c54a39064ac59e2b8fdbd Author: Justin Squirek Date: Thu Jun 30 16:20:52 2022 +0000 [Ada] Fix CodePeer warnings in GNAT sources This patch fixes various redundant constructs or uninitialized variables identified by CodePeer in the GNAT frontend and runtime sources. gcc/ada/ * exp_ch6.adb (Expand_N_Extended_Return_Statement): Add default initialization for Stmts. * sem_ch12.adb (Analyze_Associations): Add default initialization for Match. * libgnat/a-ztenau.adb (Scan_Enum_Lit): Remove duplicated boolean test. * libgnat/g-spipat.adb (XMatch): Combine duplicated cases. Diff: --- gcc/ada/exp_ch6.adb | 2 +- gcc/ada/libgnat/a-ztenau.adb | 2 - gcc/ada/libgnat/g-spipat.adb | 128 +++++-------------------------------------- gcc/ada/sem_ch12.adb | 2 +- 4 files changed, 17 insertions(+), 117 deletions(-) diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index bf51e64c463..fad130da350 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -5175,7 +5175,7 @@ package body Exp_Ch6 is Exp : Node_Id; HSS : Node_Id; Result : Node_Id; - Stmts : List_Id; + Stmts : List_Id := No_List; Return_Stmt : Node_Id := Empty; -- Force initialization to facilitate static analysis diff --git a/gcc/ada/libgnat/a-ztenau.adb b/gcc/ada/libgnat/a-ztenau.adb index b03ad8fcd99..d66e547c501 100644 --- a/gcc/ada/libgnat/a-ztenau.adb +++ b/gcc/ada/libgnat/a-ztenau.adb @@ -303,8 +303,6 @@ package body Ada.Wide_Wide_Text_IO.Enumeration_Aux is exit when Is_Character (WC) - and then - not Is_Letter (To_Character (WC)) and then not Is_Letter (To_Character (WC)) and then diff --git a/gcc/ada/libgnat/g-spipat.adb b/gcc/ada/libgnat/g-spipat.adb index 6ecbd1bb790..9fb55bc47ed 100644 --- a/gcc/ada/libgnat/g-spipat.adb +++ b/gcc/ada/libgnat/g-spipat.adb @@ -3961,7 +3961,7 @@ package body GNAT.Spitbol.Patterns is -- Any (one character case) - when PC_Any_CH => + when PC_Any_CH | PC_Char => if Cursor < Length and then Subject (Cursor + 1) = Node.Char then @@ -4103,9 +4103,10 @@ package body GNAT.Spitbol.Patterns is Pop_Region; goto Succeed; - -- Assign on match. This node sets up for the eventual assignment + -- Write/assign on match. This node sets up for the eventual write + -- or assignment. - when PC_Assign_OnM => + when PC_Assign_OnM | PC_Write_OnM => Stack (Stack_Base - 1).Node := Node; Push (CP_Assign'Access); Pop_Region; @@ -4144,9 +4145,9 @@ package body GNAT.Spitbol.Patterns is Push (Node); goto Succeed; - -- Break (one character case) + -- Break & BreakX (one character case) - when PC_Break_CH => + when PC_Break_CH | PC_BreakX_CH => while Cursor < Length loop if Subject (Cursor + 1) = Node.Char then goto Succeed; @@ -4157,9 +4158,9 @@ package body GNAT.Spitbol.Patterns is goto Fail; - -- Break (character set case) + -- Break & BreakX (character set case) - when PC_Break_CS => + when PC_Break_CS | PC_BreakX_CS => while Cursor < Length loop if Is_In (Subject (Cursor + 1), Node.CS) then goto Succeed; @@ -4170,9 +4171,9 @@ package body GNAT.Spitbol.Patterns is goto Fail; - -- Break (string function case) + -- Break & BreakX (string function case) - when PC_Break_VF => declare + when PC_Break_VF | PC_BreakX_VF => declare U : constant VString := Node.VF.all; S : Big_String_Access; L : Natural; @@ -4191,77 +4192,9 @@ package body GNAT.Spitbol.Patterns is goto Fail; end; - -- Break (string pointer case) + -- Break & BreakX (string pointer case) - when PC_Break_VP => declare - U : constant VString := Node.VP.all; - S : Big_String_Access; - L : Natural; - - begin - Get_String (U, S, L); - - while Cursor < Length loop - if Is_In (Subject (Cursor + 1), S (1 .. L)) then - goto Succeed; - else - Cursor := Cursor + 1; - end if; - end loop; - - goto Fail; - end; - - -- BreakX (one character case) - - when PC_BreakX_CH => - while Cursor < Length loop - if Subject (Cursor + 1) = Node.Char then - goto Succeed; - else - Cursor := Cursor + 1; - end if; - end loop; - - goto Fail; - - -- BreakX (character set case) - - when PC_BreakX_CS => - while Cursor < Length loop - if Is_In (Subject (Cursor + 1), Node.CS) then - goto Succeed; - else - Cursor := Cursor + 1; - end if; - end loop; - - goto Fail; - - -- BreakX (string function case) - - when PC_BreakX_VF => declare - U : constant VString := Node.VF.all; - S : Big_String_Access; - L : Natural; - - begin - Get_String (U, S, L); - - while Cursor < Length loop - if Is_In (Subject (Cursor + 1), S (1 .. L)) then - goto Succeed; - else - Cursor := Cursor + 1; - end if; - end loop; - - goto Fail; - end; - - -- BreakX (string pointer case) - - when PC_BreakX_VP => declare + when PC_Break_VP | PC_BreakX_VP => declare U : constant VString := Node.VP.all; S : Big_String_Access; L : Natural; @@ -4288,18 +4221,6 @@ package body GNAT.Spitbol.Patterns is Cursor := Cursor + 1; goto Succeed; - -- Character (one character string) - - when PC_Char => - if Cursor < Length - and then Subject (Cursor + 1) = Node.Char - then - Cursor := Cursor + 1; - goto Succeed; - else - goto Fail; - end if; - -- End of Pattern when PC_EOP => @@ -4941,15 +4862,6 @@ package body GNAT.Spitbol.Patterns is Subject (Stack (Stack_Base - 1).Cursor + 1 .. Cursor)); Pop_Region; goto Succeed; - - -- Write on match. This node sets up for the eventual write - - when PC_Write_OnM => - Stack (Stack_Base - 1).Node := Node; - Push (CP_Assign'Access); - Pop_Region; - Assign_OnM := True; - goto Succeed; end case; -- We are NOT allowed to fall though this case statement, since every @@ -5445,20 +5357,10 @@ package body GNAT.Spitbol.Patterns is goto Fail; end if; - -- Arbno_S (simple Arbno initialize). This is the node that - -- initiates the match of a simple Arbno structure. - - when PC_Arbno_S => - Dout (Img (Node) & - "setting up Arbno alternative " & Img (Node.Alt)); - Push (Node.Alt); - Node := Node.Pthen; - goto Match; - - -- Arbno_X (Arbno initialize). This is the node that initiates - -- the match of a complex Arbno structure. + -- Arbno_S/X (simple and complex Arbno initialize). This is the node + -- that initiates the match of a simple or complex Arbno structure. - when PC_Arbno_X => + when PC_Arbno_S | PC_Arbno_X => Dout (Img (Node) & "setting up Arbno alternative " & Img (Node.Alt)); Push (Node.Alt); diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index c980d7bb0ce..9525140b45b 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -1113,7 +1113,7 @@ package body Sem_Ch12 is Analyzed_Formal : Node_Id; First_Named : Node_Id := Empty; Formal : Node_Id; - Match : Node_Id; + Match : Node_Id := Empty; Named : Node_Id; Saved_Formal : Node_Id;