From 7c784ca077ce181bb247c6f17407da5ee0b46b0c Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Wed, 5 Apr 2023 13:56:42 +0200 Subject: [PATCH] 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. --- gcc/ada/exp_ch6.adb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index bd4f4a1412d3..87560462315e 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 -- 2.47.2