OSDN Git Service

2005-10-20 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Oct 2005 15:19:03 +0000 (15:19 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Oct 2005 15:19:03 +0000 (15:19 +0000)
PR c++/24439
* fold-const.c (invert_truthvalue): Handle COND_EXPR with
void type operands.

* g++.dg/tree-ssa/pr24439.C: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105678 138bc75d-0d04-0410-961f-82ee72b054a4

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

index e5de23f..e3a9a8f 100644 (file)
@@ -1,3 +1,9 @@
+2005-10-20  Richard Guenther  <rguenther@suse.de>
+
+       PR c++/24439
+       * fold-const.c (invert_truthvalue): Handle COND_EXPR with
+       void type operands.
+
 2005-10-20  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        PR rtl-optimization/23585
index a6aa1df..16e7eb3 100644 (file)
@@ -3025,9 +3025,18 @@ invert_truthvalue (tree arg)
       return TREE_OPERAND (arg, 0);
 
     case COND_EXPR:
-      return build3 (COND_EXPR, type, TREE_OPERAND (arg, 0),
-                    invert_truthvalue (TREE_OPERAND (arg, 1)),
-                    invert_truthvalue (TREE_OPERAND (arg, 2)));
+      {
+       tree arg1 = TREE_OPERAND (arg, 1);
+       tree arg2 = TREE_OPERAND (arg, 2);
+       /* A COND_EXPR may have a throw as one operand, which
+          then has void type.  Just leave void operands
+          as they are.  */
+       return build3 (COND_EXPR, type, TREE_OPERAND (arg, 0),
+                      VOID_TYPE_P (TREE_TYPE (arg1))
+                      ? arg1 : invert_truthvalue (arg1),
+                      VOID_TYPE_P (TREE_TYPE (arg2))
+                      ? arg2 : invert_truthvalue (arg2));
+      }
 
     case COMPOUND_EXPR:
       return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg, 0),
index 82e1f04..b94bce8 100644 (file)
@@ -1,3 +1,8 @@
+2005-10-20  Richard Guenther  <rguenther@suse.de>
+
+       PR c++/24439
+       * g++.dg/tree-ssa/pr24439.C: New testcase.
+
 2005-10-20  Eric Botcazou  <ebotcazou@libertysurf.fr>
 
        * g++.dg/opt/delay-slot-1.C: New test.
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr24439.C b/gcc/testsuite/g++.dg/tree-ssa/pr24439.C
new file mode 100644 (file)
index 0000000..74576b5
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+/* We used to ICE in invert_truthvalue on the void type
+   2nd argument of the COND_EXPR.  */
+
+void foo(void)
+{
+  int value=1;
+  !(value?true:throw);
+}