diff options
author | Bob Duff <duff@adacore.com> | 2022-06-23 12:29:22 -0400 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2022-07-12 12:24:12 +0000 |
commit | 6a64ee3903166dcb1a7803fbf49c31d0f89875a8 (patch) | |
tree | 171d28ecdb42c209b974001827b72854f9166a62 /gcc/ada/sem_res.adb | |
parent | 6882d60a10060a7f3c73e73eb7f10239e1a4f905 (diff) | |
download | gcc-6a64ee3903166dcb1a7803fbf49c31d0f89875a8.zip gcc-6a64ee3903166dcb1a7803fbf49c31d0f89875a8.tar.gz gcc-6a64ee3903166dcb1a7803fbf49c31d0f89875a8.tar.bz2 |
[Ada] Remove out-of-range warning in unreachable code
This patch removes a warning in examples like this:
if cond then
return; -- or other jump
end if;
X := ...; -- where the value is out of range
where cond is known at compile time. It could, for example, be a generic
formal parameter that is known to be True in some instances.
As a side effect, this patch adds new warnings about unreachable code.
gcc/ada/
* gnatls.adb (Output_License_Information): Remove pragma
No_Return; call sites deal with Exit_Program.
* libgnat/g-socthi.adb (C_Connect): Suppress warning about
unreachable code.
* sem_ch5.adb (Check_Unreachable_Code): Special-case if
statements with static conditions. If we remove unreachable
code (including the return statement) from a function, add
"raise Program_Error", so we won't warn about missing returns.
Remove Original_Node in test for N_Raise_Statement; it's not
needed. Remove test for CodePeer_Mode; if Operating_Mode =
Generate_Code, then CodePeer_Mode can't be True. Misc cleanup.
Do not reuse Nxt variable for unrelated purpose (the usage in
the Kill_Dead_Code loop is entirely local to the loop).
* sem_ch6.adb: Add check for Is_Transfer. Misc cleanup.
* sem_prag.adb: Minor.
* sem_res.adb: Minor.
* sem_util.adb: Minor cleanup.
(Is_Trivial_Boolean): Move to nonnested place, so it can be
called from elsewhere.
(Is_Static_Constant_Boolean): New function.
* sem_util.ads (Is_Trivial_Boolean): Export.
(Is_Static_Constant_Boolean): New function.
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r-- | gcc/ada/sem_res.adb | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb index 4335940..44fc955 100644 --- a/gcc/ada/sem_res.adb +++ b/gcc/ada/sem_res.adb @@ -7196,9 +7196,7 @@ package body Sem_Res is -- Check unreachable code after calls to procedures with No_Return - if Ekind (Nam) = E_Procedure - and then No_Return (Nam) - then + if Ekind (Nam) = E_Procedure and then No_Return (Nam) then Check_Unreachable_Code (N); end if; |