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
This commit is contained in:
Richard Guenther 2005-10-20 15:19:03 +00:00 committed by Richard Biener
parent 2358ff9116
commit 9ca4afb947
4 changed files with 33 additions and 3 deletions

View 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

View 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),

View 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.

View File

@ -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);
}