re PR c++/24439 (ICE with invert conditional containing throw)
authorRichard Guenther <rguenther@suse.de>
Thu, 20 Oct 2005 15:19:03 +0000 (15:19 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 20 Oct 2005 15:19:03 +0000 (15:19 +0000)
2005-10-20  Richard Guenther  <rguenther@suse.de>

PR c++/24439
* fold-const.c (invert_truthvalue): Handle COND_EXPR with
void type operands.

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

From-SVN: r105678

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

index e5de23f842136c248035759a8aa82597158f8ba5..e3a9a8fa564a090f574c4edb73f15b65a79fb6b7 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 a6aa1df818c4785f6eadfb36f54b90985b3eb2ee..16e7eb30b307587b576f2dd8b91f9c9a6ba17f62 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 82e1f048e183958ccc19bcfe0f67ef7c247591da..b94bce86936e8e2a3f466961bb54af913135cd17 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);
+}