re PR middle-end/33641 (perlbmk gets type mismatch in pointer plus expression)

2007-10-04  Richard Guenther  <rguenther@suse.de>

	PR middle-end/33641
	* tree-cfg.c (verify_gimple_expr): Operand one of POINTER_PLUS_EXPR
	does not need to be of INTEGER_TYPE.
	(verify_gimple_2): New function split out from ...
	(verify_gimple_1): ... here.  ICE if there was an error during
	verification.

	* gcc.c-torture/compile/pr33641.c: New testcase.

From-SVN: r129010
This commit is contained in:
Richard Guenther 2007-10-04 14:35:32 +00:00 committed by Richard Biener
parent fa33a305e2
commit 7dc83ebc4a
4 changed files with 54 additions and 11 deletions

View File

@ -1,3 +1,12 @@
2007-10-04 Richard Guenther <rguenther@suse.de>
PR middle-end/33641
* tree-cfg.c (verify_gimple_expr): Operand one of POINTER_PLUS_EXPR
does not need to be of INTEGER_TYPE.
(verify_gimple_2): New function split out from ...
(verify_gimple_1): ... here. ICE if there was an error during
verification.
2007-10-04 Michael Matz <matz@suse.de>
PR rtl-optimization/33653

View File

@ -1,3 +1,8 @@
2007-10-04 Richard Guenther <rguenther@suse.de>
PR middle-end/33641
* gcc.c-torture/compile/pr33641.c: New testcase.
2007-10-04 Michael Matz <matz@suse.de>
PR rtl-optimization/33653

View File

@ -0,0 +1,12 @@
/* This failed with type checking enabled. */
typedef enum { one, two } exp;
extern exp pe;
extern char pt[256];
void psd (void (*f) (void *), void *p);
static void rle (void *e) { }
void
foo (void)
{
psd ((void (*)(void *)) (rle), (void *) (pt + pe));
}

View File

@ -3724,7 +3724,6 @@ verify_gimple_expr (tree expr)
return true;
}
if (!POINTER_TYPE_P (TREE_TYPE (op0))
|| TREE_CODE (TREE_TYPE (op1)) != INTEGER_TYPE
|| !useless_type_conversion_p (type, TREE_TYPE (op0))
|| !useless_type_conversion_p (sizetype, TREE_TYPE (op1)))
{
@ -4023,12 +4022,14 @@ verify_gimple_stmt (tree stmt)
}
}
/* Verify the GIMPLE statements inside the statement list STMTS. */
/* Verify the GIMPLE statements inside the statement list STMTS.
Returns true if there were any errors. */
void
verify_gimple_1 (tree stmts)
static bool
verify_gimple_2 (tree stmts)
{
tree_stmt_iterator tsi;
bool err = false;
for (tsi = tsi_start (stmts); !tsi_end_p (tsi); tsi_next (&tsi))
{
@ -4037,28 +4038,44 @@ verify_gimple_1 (tree stmts)
switch (TREE_CODE (stmt))
{
case BIND_EXPR:
verify_gimple_1 (BIND_EXPR_BODY (stmt));
err |= verify_gimple_2 (BIND_EXPR_BODY (stmt));
break;
case TRY_CATCH_EXPR:
case TRY_FINALLY_EXPR:
verify_gimple_1 (TREE_OPERAND (stmt, 0));
verify_gimple_1 (TREE_OPERAND (stmt, 1));
err |= verify_gimple_2 (TREE_OPERAND (stmt, 0));
err |= verify_gimple_2 (TREE_OPERAND (stmt, 1));
break;
case CATCH_EXPR:
verify_gimple_1 (CATCH_BODY (stmt));
err |= verify_gimple_2 (CATCH_BODY (stmt));
break;
case EH_FILTER_EXPR:
verify_gimple_1 (EH_FILTER_FAILURE (stmt));
err |= verify_gimple_2 (EH_FILTER_FAILURE (stmt));
break;
default:
if (verify_gimple_stmt (stmt))
debug_generic_expr (stmt);
{
bool err2 = verify_gimple_stmt (stmt);
if (err2)
debug_generic_expr (stmt);
err |= err2;
}
}
}
return err;
}
/* Verify the GIMPLE statements inside the statement list STMTS. */
void
verify_gimple_1 (tree stmts)
{
if (verify_gimple_2 (stmts))
internal_error ("verify_gimple failed");
}
/* Verify the GIMPLE statements inside the current function. */