aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/sem_res.adb
diff options
context:
space:
mode:
authorPiotr Trojanek <trojanek@adacore.com>2022-06-03 15:18:24 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2022-07-12 12:24:11 +0000
commit1710ba9e5d09493690c5f474a5c37b5c8f5d7b19 (patch)
tree8e0d8ef1e695dcbd46c435df9b6c1dee75a90edd /gcc/ada/sem_res.adb
parent2148f2996ae76a7773eb7d8e30c02bd036ec7b3c (diff)
downloadgcc-1710ba9e5d09493690c5f474a5c37b5c8f5d7b19.zip
gcc-1710ba9e5d09493690c5f474a5c37b5c8f5d7b19.tar.gz
gcc-1710ba9e5d09493690c5f474a5c37b5c8f5d7b19.tar.bz2
[Ada] Warn about unreachable code after calls with No_Return
GNAT was already warning about unreachable code after raise/goto/exit statements, but not after calls to procedures with No_Return. Now this warning is extended. Also, previously the warning was suppressed for unreachable RETURN after RAISE statements. Now this suppression is narrowed to functions, because only in function such a RETURN statement might be indeed needed (where it is the only RETURN statement of a function). gcc/ada/ * sem_ch5.adb (Check_Unreachable_Code): Extend suppression to calls with No_Return aspect, but narrow it to functions. * sem_res.adb (Resolve_Call): Warn about unreachable code after calls with No_Return.
Diffstat (limited to 'gcc/ada/sem_res.adb')
-rw-r--r--gcc/ada/sem_res.adb9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 1053cec..4335940 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -62,6 +62,7 @@ with Sem_Case; use Sem_Case;
with Sem_Cat; use Sem_Cat;
with Sem_Ch3; use Sem_Ch3;
with Sem_Ch4; use Sem_Ch4;
+with Sem_Ch5; use Sem_Ch5;
with Sem_Ch6; use Sem_Ch6;
with Sem_Ch8; use Sem_Ch8;
with Sem_Ch13; use Sem_Ch13;
@@ -7193,6 +7194,14 @@ package body Sem_Res is
Analyze_Dimension_Call (N, Nam);
+ -- Check unreachable code after calls to procedures with No_Return
+
+ if Ekind (Nam) = E_Procedure
+ and then No_Return (Nam)
+ then
+ Check_Unreachable_Code (N);
+ end if;
+
-- All done, evaluate call and deal with elaboration issues
Eval_Call (N);