From 9fde6c7114f079b38ebee420a541e14387bcc928 Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Thu, 2 Jun 2022 17:32:15 +0200 Subject: [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. --- gcc/ada/sem_attr.adb | 3 --- 1 file changed, 3 deletions(-) (limited to 'gcc/ada/sem_attr.adb') diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index be60087..6a35358 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 -- cgit v1.1