aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2005-10-20 15:19:03 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2005-10-20 15:19:03 +0000
commit9ca4afb947aa1edc2da5d4d8f809f92eb5b7149c (patch)
treea54c3badb757d1310e8ac6ecfbb2e2f11d6caaf3
parent2358ff9116d8167e4b0d2f70a9d61e4e8ca5168e (diff)
downloadgcc-9ca4afb947aa1edc2da5d4d8f809f92eb5b7149c.zip
gcc-9ca4afb947aa1edc2da5d4d8f809f92eb5b7149c.tar.gz
gcc-9ca4afb947aa1edc2da5d4d8f809f92eb5b7149c.tar.bz2
re PR c++/24439 (ICE with invert conditional containing throw)
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
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/fold-const.c15
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/g++.dg/tree-ssa/pr24439.C10
4 files changed, 33 insertions, 3 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e5de23f..e3a9a8f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index a6aa1df..16e7eb3 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -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),
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 82e1f04..b94bce8 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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
index 0000000..74576b5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr24439.C
@@ -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);
+}