re PR middle-end/24227 (ICE in compare_values, at tree-vrp.c:415)
authorRichard Guenther <rguenther@suse.de>
Fri, 7 Oct 2005 18:12:11 +0000 (18:12 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 7 Oct 2005 18:12:11 +0000 (18:12 +0000)
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

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr24227.c [new file with mode: 0644]

index e0930b0..7964e0e 100644 (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
index 0190c32..015930e 100644 (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))
        {
index 47bd2f9..d189677 100644 (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):
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr24227.c b/gcc/testsuite/gcc.c-torture/compile/pr24227.c
new file mode 100644 (file)
index 0000000..a4bb44a
--- /dev/null
@@ -0,0 +1,6 @@
+int Fdisplay_buffer   (int buffer)
+{
+  if (((struct buffer *) ((unsigned int) buffer)) ==
+      (0,(struct buffer *) ((unsigned int) ((buffer) & 1))))
+    return 1;
+}