utils.c (max_size): Flip the second argument when recursing on TRUTH_NOT_EXPR.
authorEric Botcazou <ebotcazou@adacore.com>
Fri, 24 Feb 2017 09:52:31 +0000 (09:52 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Fri, 24 Feb 2017 09:52:31 +0000 (09:52 +0000)
* gcc-interface/utils.c (max_size) <tcc_expression>: Flip the second
argument when recursing on TRUTH_NOT_EXPR.

From-SVN: r245697

gcc/ada/ChangeLog
gcc/ada/gcc-interface/utils.c
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/discr47.adb [new file with mode: 0644]

index 053ca00254f4d5b6a5883f2c53668ef02ff1a995..a7edb4158cc318682ccda6b198b1b05816ae1a4f 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-24  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gcc-interface/utils.c (max_size) <tcc_expression>: Flip the second
+       argument when recursing on TRUTH_NOT_EXPR.
+
 2017-02-12  John Marino  <gnugcc@marino.st>
 
        * system-freebsd-x86.ads: Rename into...
index 3cda63196e7e4a2a56a82c5b8c89f3ed14fe7754..33a37cea2f6b0c90c6a511a00b29bff73e5cb892 100644 (file)
@@ -3635,7 +3635,8 @@ max_size (tree exp, bool max_p)
            return exp;
 
          return fold_build1 (code, type,
-                             max_size (TREE_OPERAND (exp, 0), max_p));
+                             max_size (TREE_OPERAND (exp, 0),
+                             code == TRUTH_NOT_EXPR ? !max_p : max_p));
 
        case 2:
          if (code == COMPOUND_EXPR)
index 6b62ae8dc0eb25bbf8e9d78c1edd102f7dcd5fd2..dc2cf4ee2affe0be484539d81736712065e982f3 100644 (file)
@@ -1,3 +1,7 @@
+2017-02-24  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * gnat.dg/discr47.adb: New test.
+
 2017-02-24  Richard Biener  <rguenther@suse.de>
 
        PR tree-optimization/79389
diff --git a/gcc/testsuite/gnat.dg/discr47.adb b/gcc/testsuite/gnat.dg/discr47.adb
new file mode 100644 (file)
index 0000000..0aaa655
--- /dev/null
@@ -0,0 +1,19 @@
+-- { dg-do run }
+-- { dg-options "-O -gnatws" }
+
+procedure Discr47 is
+
+  type Rec (D : Boolean := False) is record
+    case D is
+      when True => null;
+      when False => C : Character;
+    end case;
+  end record;
+
+  R : Rec;
+
+begin
+  if R'Size /= 16 then
+    raise Program_Error;
+  end if;
+end;