This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gomp] c++ for declarations
- From: Richard Henderson <rth at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 17 Oct 2005 20:25:25 -0700
- Subject: Re: [gomp] c++ for declarations
- References: <20051017221634.GA10441@redhat.com>
... and the reason that Diego was seeing the new test fail and
I wasn't, is that I didn't post or commit the entire patch. I
forgot about the bits in the main gcc directory.
r~
* gimplify.c (gimplify_omp_for): Canonicalize the operand order
wrt PLUS.
Index: gcc/gimplify.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/gimplify.c,v
retrieving revision 2.135.4.31
diff -u -p -r2.135.4.31 gimplify.c
--- gcc/gimplify.c 17 Oct 2005 00:40:41 -0000 2.135.4.31
+++ gcc/gimplify.c 18 Oct 2005 03:21:06 -0000
@@ -4554,8 +4554,21 @@ gimplify_omp_for (tree *expr_p, tree *pr
case MODIFY_EXPR:
gcc_assert (TREE_OPERAND (t, 0) == decl);
t = TREE_OPERAND (t, 1);
- gcc_assert (TREE_CODE (t) == PLUS_EXPR || TREE_CODE (t) == MINUS_EXPR);
- gcc_assert (TREE_OPERAND (t, 0) == decl);
+ switch (TREE_CODE (t))
+ {
+ case PLUS_EXPR:
+ if (TREE_OPERAND (t, 1) == decl)
+ {
+ TREE_OPERAND (t, 1) = TREE_OPERAND (t, 0);
+ TREE_OPERAND (t, 0) = decl;
+ break;
+ }
+ case MINUS_EXPR:
+ gcc_assert (TREE_OPERAND (t, 0) == decl);
+ break;
+ default:
+ gcc_unreachable ();
+ }
ret |= gimplify_expr (&TREE_OPERAND (t, 1), pre_p, NULL,
is_gimple_val, fb_rvalue);
break;
Index: gcc/testsuite/g++.dg/gomp/for-11.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/gomp/Attic/for-11.C,v
retrieving revision 1.1.2.1
diff -u -p -r1.1.2.1 for-11.C
--- gcc/testsuite/g++.dg/gomp/for-11.C 13 Oct 2005 01:12:27 -0000 1.1.2.1
+++ gcc/testsuite/g++.dg/gomp/for-11.C 18 Oct 2005 03:21:06 -0000
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+// { dg-do compile }
extern void baz (int);
@@ -9,6 +9,6 @@ void foo (int j, int k)
baz (l);
#pragma omp for
- for (int i = 0, m = 0; m < 10; m++)
+ for (int i = 0, m = 0; m < 10; m++) // { dg-error "" }
baz (m);
}