re PR middle-end/24227 (ICE in compare_values, at tree-vrp.c:415)

2005-10-07  Richard Guenther  <rguenther@suse.de>

	PR middle-end/24227
	* fold-const.c (fold_binary): Fix operand types during folding
	of X op (A, Y).  Evaluation order of the side-effects of
	X and A are frontend-defined, so ensure we honour that even for
	tcc_comparison class operands; eased by removing duplicate code.

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

From-SVN: r105096
This commit is contained in:
Richard Guenther 2005-10-07 18:12:11 +00:00 committed by Richard Biener
parent 002a9071e6
commit 4c17e28838
4 changed files with 24 additions and 13 deletions

View File

@ -1,3 +1,11 @@
2005-10-07 Richard Guenther <rguenther@suse.de>
PR middle-end/24227
* fold-const.c (fold_binary): Fix operand types during folding
of X op (A, Y). Evaluation order of the side-effects of
X and A are frontend-defined, so ensure we honour that even for
tcc_comparison class operands; eased by removing duplicate code.
2005-10-07 Steve Ellcey <sje@cup.hp.com>
* stor-layout.c (layout_type): Do not allow alignment of array

View File

@ -7113,26 +7113,18 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1)
return fold_convert (type, tem);
}
if (TREE_CODE_CLASS (code) == tcc_comparison
&& TREE_CODE (arg0) == COMPOUND_EXPR)
return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg0, 0),
fold_build2 (code, type, TREE_OPERAND (arg0, 1), arg1));
else if (TREE_CODE_CLASS (code) == tcc_comparison
&& TREE_CODE (arg1) == COMPOUND_EXPR)
return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg1, 0),
fold_build2 (code, type, arg0, TREE_OPERAND (arg1, 1)));
else if (TREE_CODE_CLASS (code) == tcc_binary
|| TREE_CODE_CLASS (code) == tcc_comparison)
if (TREE_CODE_CLASS (code) == tcc_binary
|| TREE_CODE_CLASS (code) == tcc_comparison)
{
if (TREE_CODE (arg0) == COMPOUND_EXPR)
return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg0, 0),
fold_build2 (code, type, TREE_OPERAND (arg0, 1),
arg1));
fold_build2 (code, type,
TREE_OPERAND (arg0, 1), op1));
if (TREE_CODE (arg1) == COMPOUND_EXPR
&& reorder_operands_p (arg0, TREE_OPERAND (arg1, 0)))
return build2 (COMPOUND_EXPR, type, TREE_OPERAND (arg1, 0),
fold_build2 (code, type,
arg0, TREE_OPERAND (arg1, 1)));
op0, TREE_OPERAND (arg1, 1)));
if (TREE_CODE (arg0) == COND_EXPR || COMPARISON_CLASS_P (arg0))
{

View File

@ -1,3 +1,8 @@
2005-10-07 Richard Guenther <rguenther@suse.de>
PR middle-end/24227
* gcc.c-torture/compile/pr24227.c: New testcase.
2005-10-07 Steve Ellcey <sje@cup.hp.com>
* gcc.dg/compat/struct-layout-1_generate.c (generate_fields):

View File

@ -0,0 +1,6 @@
int Fdisplay_buffer (int buffer)
{
if (((struct buffer *) ((unsigned int) buffer)) ==
(0,(struct buffer *) ((unsigned int) ((buffer) & 1))))
return 1;
}