]> gcc.gnu.org Git - gcc.git/commitdiff
re PR c++/33709 (Type verification failure with new expression)
authorJakub Jelinek <jakub@redhat.com>
Tue, 30 Oct 2007 22:40:13 +0000 (23:40 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Tue, 30 Oct 2007 22:40:13 +0000 (23:40 +0100)
PR c++/33709
* fold-const.c (fold_binary): If one argument is COMPOUND_EXPR,
convert second operand of COMPOUND_EXPR to the original type of
that argument.

* g++.dg/opt/compound1.C: New test.

From-SVN: r129785

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/opt/compound1.C [new file with mode: 0644]

index 14c0428daf2b787939792e6a1c21dfcc04915b52..1f0196dcbbb6ecfd5b81fc2dd814be8c1473790b 100644 (file)
@@ -1,3 +1,10 @@
+2007-10-30  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/33709
+       * fold-const.c (fold_binary): If one argument is COMPOUND_EXPR,
+       convert second operand of COMPOUND_EXPR to the original type of
+       that argument.
+
 2007-10-30  Richard Guenther  <rguenther@suse.de>
 
        * tree-ssa-operands.c (add_vars_for_offset): Fix exit test
index fd5a7085e91307ecde12774abee04bb7de100656..2598ec1e18fb779af0b82b74826f4b1517c5f183 100644 (file)
@@ -9504,12 +9504,15 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
       if (TREE_CODE (arg0) == COMPOUND_EXPR)
        return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg0, 0),
                       fold_build2 (code, type,
-                                   TREE_OPERAND (arg0, 1), op1));
+                                   fold_convert (TREE_TYPE (op0),
+                                                 TREE_OPERAND (arg0, 1)),
+                                   op1));
       if (TREE_CODE (arg1) == COMPOUND_EXPR
          && reorder_operands_p (arg0, TREE_OPERAND (arg1, 0)))
        return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg1, 0),
-                      fold_build2 (code, type,
-                                   op0, TREE_OPERAND (arg1, 1)));
+                      fold_build2 (code, type, op0,
+                                   fold_convert (TREE_TYPE (op1),
+                                                 TREE_OPERAND (arg1, 1))));
 
       if (TREE_CODE (arg0) == COND_EXPR || COMPARISON_CLASS_P (arg0))
        {
index 4fcafd01bbd2bab7d4fca8e3c88d1d294ac8f903..82dbb7a671520dd77f51676a59b3895de566f04d 100644 (file)
@@ -1,5 +1,8 @@
 2007-10-30  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/33709
+       * g++.dg/opt/compound1.C: New test.
+
        PR c++/33616
        * g++.dg/template/ptrmem18.C: New test.
 
diff --git a/gcc/testsuite/g++.dg/opt/compound1.C b/gcc/testsuite/g++.dg/opt/compound1.C
new file mode 100644 (file)
index 0000000..cf81e69
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/33709
+// { dg-do compile }
+// { dg-options "-O2" }
+
+class S {
+  virtual void foo ();
+};
+struct T {
+  S *s;
+  void bar (unsigned x) { s = (new S[1]) - x; }
+};
This page took 0.165708 seconds and 5 git commands to generate.