From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id 37A363854141; Tue, 5 Jul 2022 08:29:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37A363854141 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-1479] [Ada] Remove unnecessary dead code after calls to nonreturning procedures X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/heads/master X-Git-Oldrev: 684194f4a45e00e56687289386eea7105a762cf7 X-Git-Newrev: 9fde6c7114f079b38ebee420a541e14387bcc928 Message-Id: <20220705082948.37A363854141@sourceware.org> Date: Tue, 5 Jul 2022 08:29:48 +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: Tue, 05 Jul 2022 08:29:48 -0000 https://gcc.gnu.org/g:9fde6c7114f079b38ebee420a541e14387bcc928 commit r13-1479-g9fde6c7114f079b38ebee420a541e14387bcc928 Author: Piotr Trojanek Date: Thu Jun 2 17:32:15 2022 +0200 [Ada] Remove unnecessary dead code after calls to nonreturning procedures A new warning about unreachable code that follows calls to procedures with No_Return would flag some dead defensive code. Comments next to this code suggest that it was added to please some ancient version of the compiler, but recent releases of GNAT do not require such a code. gcc/ada/ * gnatls.adb (Corresponding_Sdep_Entry): Remove dead return statement in defensive path; there is another return statement for a normal execution of this routine, so rule Ada RM 6.5(5), which requires function to have at least one return statement is still satisfied. (Gnatls): Remove dead, call to nonreturning Exit_Program after Output_License_Information which itself does not return. * libgnat/a-exstat.adb (Bad_EO): Remove raise statement that was meant to please some ancient version of GNAT. * libgnat/g-awk.adb (Raise_With_Info): Likewise. * sem_attr.adb (Check_Reference): Remove dead return statement; rule Ada RM 6.5(5), which requires function to have at least one return statement is still satisfied. (Analyze_Attribute): Remove dead exit statement. (Check_Reference): Same as above. * sem_ch12.adb (Instantiate_Formal_Package): Remove dead raise statement; it was inconsistent with other calls to Abandon_Instantiation, which are not followed by a raise statement. * sem_prag.adb (Process_Convention): Remove dead defensive assignment. (Interrupt_State): Remove dead defensive exit statement. (Do_SPARK_Mode): Likewise. * sfn_scan.adb (Scan_String): Remove dead defensive assignment. Diff: --- gcc/ada/gnatls.adb | 2 -- gcc/ada/libgnat/a-exstat.adb | 7 ------- gcc/ada/libgnat/g-awk.adb | 1 - gcc/ada/sem_attr.adb | 3 --- gcc/ada/sem_ch12.adb | 1 - gcc/ada/sem_prag.adb | 3 --- gcc/ada/sfn_scan.adb | 1 - 7 files changed, 18 deletions(-) diff --git a/gcc/ada/gnatls.adb b/gcc/ada/gnatls.adb index 9b62f71d68e..72445268f00 100644 --- a/gcc/ada/gnatls.adb +++ b/gcc/ada/gnatls.adb @@ -319,7 +319,6 @@ procedure Gnatls is Write_Eol; Error_Msg ("wrong ALI format, can't find dependency line for $ in {"); Exit_Program (E_Fatal); - return No_Sdep_Id; end Corresponding_Sdep_Entry; ------------------------- @@ -2051,7 +2050,6 @@ begin if License then if Arg_Count = 2 then Output_License_Information; - Exit_Program (E_Success); else Set_Standard_Error; diff --git a/gcc/ada/libgnat/a-exstat.adb b/gcc/ada/libgnat/a-exstat.adb index a3f808eada8..acc251649cd 100644 --- a/gcc/ada/libgnat/a-exstat.adb +++ b/gcc/ada/libgnat/a-exstat.adb @@ -109,13 +109,6 @@ package body Stream_Attributes is Raise_Exception (Program_Error'Identity, "bad exception occurrence in stream input"); - - -- The following junk raise of Program_Error is required because - -- this is a No_Return procedure, and unfortunately Raise_Exception - -- can return (this particular call can't, but the back end is not - -- clever enough to know that). - - raise Program_Error; end Bad_EO; procedure Next_String is diff --git a/gcc/ada/libgnat/g-awk.adb b/gcc/ada/libgnat/g-awk.adb index 1c887853fa9..9b2e127b3bb 100644 --- a/gcc/ada/libgnat/g-awk.adb +++ b/gcc/ada/libgnat/g-awk.adb @@ -1211,7 +1211,6 @@ package body GNAT.AWK is Exceptions.Raise_Exception (E, '[' & Filename & ':' & Line & "] " & Message); - raise Constraint_Error; -- to please GNAT as this is a No_Return proc end Raise_With_Info; --------------- diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index be600872a1d..6a35358261e 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -4747,7 +4747,6 @@ package body Sem_Attr is Error_Attr ("prefix of attribute % cannot reference local entities", Nod); - return Abandon; else return OK; end if; @@ -4989,7 +4988,6 @@ package body Sem_Attr is else Error_Attr ("attribute % cannot appear in body or accept statement", N); - exit; end if; end loop; @@ -5383,7 +5381,6 @@ package body Sem_Attr is Error_Attr ("prefix of attribute % cannot reference local entities", Nod); - return Abandon; -- Otherwise keep inspecting the prefix diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index c5f2eed96fd..dcc0dac4342 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -10572,7 +10572,6 @@ package body Sem_Ch12 is Error_Msg_N ("expect package instance to instantiate formal", Actual); Abandon_Instantiation (Actual); - raise Program_Error; else Actual_Pack := Entity (Actual); diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 89c45da10bb..3660c75fc69 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -8336,7 +8336,6 @@ package body Sem_Prag is Error_Pragma_Arg ("argument of pragma% must be subprogram or access type", Arg2); - Subp := Empty; end if; -- ISO C requires a named parameter before the ellipsis, so a @@ -18641,7 +18640,6 @@ package body Sem_Prag is Interrupt_States.Table (IST_Num).Pragma_Loc; Error_Pragma_Arg ("state conflicts with that given #", Arg2); - exit; end if; IST_Num := IST_Num + 1; @@ -23762,7 +23760,6 @@ package body Sem_Prag is else Pragma_Misplaced; - exit; end if; Prev (Stmt); diff --git a/gcc/ada/sfn_scan.adb b/gcc/ada/sfn_scan.adb index b6ab92fe46b..b428ed7f0cf 100644 --- a/gcc/ada/sfn_scan.adb +++ b/gcc/ada/sfn_scan.adb @@ -622,7 +622,6 @@ package body SFN_Scan is Q := '%'; else Error ("bad string"); - Q := '"'; end if; -- Scan out the string, B points to first char