]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Bad expansion with -gnato2 and if expression
authorArnaud Charlet <charlet@adacore.com>
Fri, 22 Jan 2021 13:55:13 +0000 (08:55 -0500)
committerPierre-Marie de Rodat <derodat@adacore.com>
Thu, 6 May 2021 07:51:42 +0000 (03:51 -0400)
gcc/ada/

* exp_ch4.adb (Expand_N_If_Expression):
Apply_Arithmetic_Overflow_Check will not deal with
Then/Else_Actions so skip minimizing overflow checks if any
actions are present.

gcc/ada/exp_ch4.adb

index c88f7911cf8182b8c9c1d7074a3d9de084cf7901..2bcda1f43bf076d091ab9f48760eac46c2ee776b 100644 (file)
@@ -5915,9 +5915,14 @@ package body Exp_Ch4 is
    --  Start of processing for Expand_N_If_Expression
 
    begin
-      --  Check for MINIMIZED/ELIMINATED overflow mode
+      --  Check for MINIMIZED/ELIMINATED overflow mode.
+      --  Apply_Arithmetic_Overflow_Check will not deal with Then/Else_Actions
+      --  so skip this step if any actions are present.
 
-      if Minimized_Eliminated_Overflow_Check (N) then
+      if Minimized_Eliminated_Overflow_Check (N)
+        and then No (Then_Actions (N))
+        and then No (Else_Actions (N))
+      then
          Apply_Arithmetic_Overflow_Check (N);
          return;
       end if;