]> gcc.gnu.org Git - gcc.git/commit - gcc/ada/sem_res.adb
[Ada] Remove out-of-range warning in unreachable code
authorBob Duff <duff@adacore.com>
Thu, 23 Jun 2022 16:29:22 +0000 (12:29 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 12 Jul 2022 12:24:12 +0000 (12:24 +0000)
commit6a64ee3903166dcb1a7803fbf49c31d0f89875a8
tree171d28ecdb42c209b974001827b72854f9166a62
parent6882d60a10060a7f3c73e73eb7f10239e1a4f905
[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.
gcc/ada/gnatls.adb
gcc/ada/libgnat/g-socthi.adb
gcc/ada/sem_ch5.adb
gcc/ada/sem_ch6.adb
gcc/ada/sem_prag.adb
gcc/ada/sem_res.adb
gcc/ada/sem_util.adb
gcc/ada/sem_util.ads
This page took 0.059833 seconds and 5 git commands to generate.