This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gomp] fix privatization of loop iterator variable
- From: Richard Henderson <rth at twiddle dot net>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 27 Sep 2005 23:05:22 -0700
- Subject: [gomp] fix privatization of loop iterator variable
Doh.
r~
* c-decl.c (lookup_name): Honor omp_remap_private.
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.662.4.6
diff -u -p -r1.662.4.6 c-decl.c
--- c-decl.c 27 Sep 2005 23:35:22 -0000 1.662.4.6
+++ c-decl.c 28 Sep 2005 06:03:12 -0000
@@ -2835,7 +2835,8 @@ lookup_name (tree name)
/* Re-bind the decl to something in scope of the omp parallel. */
if (b->depth < pscope->depth)
- return c_omp_remap_decl_1 (pscope, b->decl, -1, did_error);
+ return c_omp_remap_decl_1 (pscope, b->decl, omp_remap_private ? 0 : -1,
+ did_error);
}
return b->decl;
Index: testsuite/gcc.dg/gomp/for-13.c
===================================================================
RCS file: testsuite/gcc.dg/gomp/for-13.c
diff -N testsuite/gcc.dg/gomp/for-13.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/gomp/for-13.c 28 Sep 2005 06:03:12 -0000
@@ -0,0 +1,18 @@
+// At one point in development, a typo disabled the remapping of the
+// for iteration variable as private.
+
+// { dg-do compile }
+// { dg-options "-fopenmp -fdump-tree-gimple" }
+
+extern void bar(int);
+void foo(void)
+{
+ int i;
+
+#pragma omp parallel for default(none)
+ for (i = 0; i < 10; i++)
+ bar(i);
+}
+
+// { dg-final { scan-tree-dump-times "shared" 0 "gimple" } }
+// { dg-final { cleanup-tree-dump "gimple" } }