]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix small fallout of previous change
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 5 Apr 2023 11:56:42 +0000 (13:56 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Mon, 29 May 2023 08:23:20 +0000 (10:23 +0200)
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

index bd4f4a1412d3d0d15e06c6ccd320322084c46421..87560462315ef4fa3e5370fa74155fd6cf5c3c54 100644 (file)
@@ -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