From 4c17e288380c5b3ff5350fbe83357e077b9213d5 Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Fri, 7 Oct 2005 18:12:11 +0000 Subject: [PATCH] re PR middle-end/24227 (ICE in compare_values, at tree-vrp.c:415) 2005-10-07 Richard Guenther 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 --- gcc/ChangeLog | 8 ++++++++ gcc/fold-const.c | 18 +++++------------- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.c-torture/compile/pr24227.c | 6 ++++++ 4 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr24227.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e0930b0ef7f..7964e0ec911 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2005-10-07 Richard Guenther + + 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 * stor-layout.c (layout_type): Do not allow alignment of array diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 0190c322dc5..015930e5ca6 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -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)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 47bd2f90f7a..d189677cebe 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2005-10-07 Richard Guenther + + PR middle-end/24227 + * gcc.c-torture/compile/pr24227.c: New testcase. + 2005-10-07 Steve Ellcey * gcc.dg/compat/struct-layout-1_generate.c (generate_fields): diff --git a/gcc/testsuite/gcc.c-torture/compile/pr24227.c b/gcc/testsuite/gcc.c-torture/compile/pr24227.c new file mode 100644 index 00000000000..a4bb44ad47c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr24227.c @@ -0,0 +1,6 @@ +int Fdisplay_buffer (int buffer) +{ + if (((struct buffer *) ((unsigned int) buffer)) == + (0,(struct buffer *) ((unsigned int) ((buffer) & 1)))) + return 1; +} -- 2.30.2