]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Handle case-expression inside if-expression in -gnato2
authorEtienne Servais <servais@adacore.com>
Tue, 8 Mar 2022 13:49:55 +0000 (14:49 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 16 May 2022 08:42:04 +0000 (08:42 +0000)
gcc/ada/

* checks.adb (Apply_Arithmetic_Overflow_Minimized_Eliminated):
Fix condition to return.

gcc/ada/checks.adb

index 9950c18347ce6d22cad1ff17054cce4c52b7e932..14f4f95f88ccabab945dc65498d87bcde66c48d6 100644 (file)
@@ -1237,11 +1237,16 @@ package body Checks is
          --  ops, but if they appear in an assignment or similar contexts
          --  there is no overflow check that starts from that parent node,
          --  so apply check now.
+         --  Similarly, if these expressions are nested, we should go on.
 
          if Nkind (P) in N_If_Expression | N_Case_Expression
            and then not Is_Signed_Integer_Arithmetic_Op (Parent (P))
          then
             null;
+         elsif Nkind (P) in N_If_Expression | N_Case_Expression
+            and then Nkind (Op) in N_If_Expression | N_Case_Expression
+         then
+            null;
          else
             return;
          end if;