aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-04-05 13:56:42 +0200
committerMarc Poulhiès <poulhies@adacore.com>2023-05-29 10:23:20 +0200
commit7c784ca077ce181bb247c6f17407da5ee0b46b0c (patch)
tree648083950d3f84bc719ce1ac35153678dc5635ca
parent21b0ecb9853071f0642ee1fba7861e69789d0727 (diff)
downloadgcc-7c784ca077ce181bb247c6f17407da5ee0b46b0c.zip
gcc-7c784ca077ce181bb247c6f17407da5ee0b46b0c.tar.gz
gcc-7c784ca077ce181bb247c6f17407da5ee0b46b0c.tar.bz2
ada: Fix small fallout of previous change
The same guard must be added to Expand_Simple_Function_Return as the one that was added to Analyze_Function_Return. gcc/ada/ * exp_ch6.adb (Expand_Simple_Function_Return): Deal with a rewriting of the simple return during the adjustment of its expression.
-rw-r--r--gcc/ada/exp_ch6.adb7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index bd4f4a1..8756046 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -6641,6 +6641,13 @@ package body Exp_Ch6 is
if Is_Boolean_Type (Exp_Typ) and then Nonzero_Is_True (Exp_Typ) then
Adjust_Condition (Exp);
Adjust_Result_Type (Exp, Exp_Typ);
+
+ -- The adjustment of the expression may have rewritten the return
+ -- statement itself, e.g. when it is turned into an if expression.
+
+ if Nkind (N) /= N_Simple_Return_Statement then
+ return;
+ end if;
end if;
-- Do validity check if enabled for returns