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.
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