re PR tree-optimization/17512 (ICE in regex.c)

PR tree-optimization/17512
	* convert.c (convert_to_integer): Don't handle TRUTH_*_EXPR as
	special cases.

	* testsuite/gcc.c-torture/compile/20040916-1.c.

From-SVN: r87870
This commit is contained in:
Kazu Hirata 2004-09-22 18:02:08 +00:00 committed by Kazu Hirata
parent 39cf49a113
commit a338ab5a5a
4 changed files with 24 additions and 22 deletions

View File

@ -1,3 +1,9 @@
2004-09-22 Kazu Hirata <kazu@cs.umass.edu>
PR tree-optimization/17512
* convert.c (convert_to_integer): Don't handle TRUTH_*_EXPR as
special cases.
2004-09-22 David Edelsohn <edelsohn@gnu.org>
* dbxout.c (get_lang_number): Do not define if

View File

@ -397,9 +397,7 @@ convert_to_integer (tree type, tree expr)
case BOOLEAN_TYPE:
case CHAR_TYPE:
/* If this is a logical operation, which just returns 0 or 1, we can
change the type of the expression. For some logical operations,
we must also change the types of the operands to maintain type
correctness. */
change the type of the expression. */
if (TREE_CODE_CLASS (ex_form) == tcc_comparison)
{
@ -408,25 +406,6 @@ convert_to_integer (tree type, tree expr)
return expr;
}
else if (ex_form == TRUTH_AND_EXPR || ex_form == TRUTH_ANDIF_EXPR
|| ex_form == TRUTH_OR_EXPR || ex_form == TRUTH_ORIF_EXPR
|| ex_form == TRUTH_XOR_EXPR)
{
expr = copy_node (expr);
TREE_OPERAND (expr, 0) = convert (type, TREE_OPERAND (expr, 0));
TREE_OPERAND (expr, 1) = convert (type, TREE_OPERAND (expr, 1));
TREE_TYPE (expr) = type;
return expr;
}
else if (ex_form == TRUTH_NOT_EXPR)
{
expr = copy_node (expr);
TREE_OPERAND (expr, 0) = convert (type, TREE_OPERAND (expr, 0));
TREE_TYPE (expr) = type;
return expr;
}
/* If we are widening the type, put in an explicit conversion.
Similarly if we are not changing the width. After this, we know
we are truncating EXPR. */

View File

@ -1,3 +1,8 @@
2004-09-22 Kazu Hirata <kazu@cs.umass.edu>
PR tree-optimization/17512
* gcc.c-torture/compile/20040916-1.c.
2004-09-21 Mark Mitchell <mark@codesourcery.com>
* gcc.dg/pragma-re-3.c: New test.

View File

@ -0,0 +1,12 @@
/* PR tree-optimization/17512
We used to try to fold "(char) (X ^ Y)", where '^' is
TRUTH_XOR_EXPR into ((char) X ^ (char) Y), creating TRUTH_XOR_EXPR
with its operands being of type char, which is invalid. */
char
foo (int p)
{
int q = p;
return (p != 0) == (p == q);
}