diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 38ce1cff59452b3265e2c271ab3d96503528f334..ef3bf5fb4fd1e3b9e73dd71441618eae86028c17 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,8 @@ 2008-06-27 Jakub Jelinek <jakub@redhat.com> + * gimplify.c (omp_is_private): Don't return true if decl + is not already private on #pragma omp for or #pragma omp parallel for. + PR debug/36617 * tree-cfg.c (struct move_stmt_d): Replace block field with orig_block and new_block fields. diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 799ccbee52cad769f53c1a5f9822231d8fad31f2..c3af34bf27ebe2b4732f7d6123e9f230c7205084 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -5060,15 +5060,16 @@ omp_is_private (struct gimplify_omp_ctx *ctx, tree decl) error ("iteration variable %qs should not be reduction", IDENTIFIER_POINTER (DECL_NAME (decl))); } - return true; + return (ctx == gimplify_omp_ctxp + || (ctx->region_type == ORT_COMBINED_PARALLEL + && gimplify_omp_ctxp->outer_context == ctx)); } if (ctx->region_type != ORT_WORKSHARE) return false; else if (ctx->outer_context) return omp_is_private (ctx->outer_context, decl); - else - return !is_global_var (decl); + return false; } /* Return true if DECL is private within a parallel region diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 086345b87ca3f00b787f579b314d861484ba0ef2..4ede6dafed7ae068067b8943220a65877db135a8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-06-27 Jakub Jelinek <jakub@redhat.com> + + * gcc.dg/gomp/pr27388-3.c: Adjust dg-final. + 2008-06-27 Richard Guenther <rguenther@suse.de> PR tree-optimization/36400 diff --git a/gcc/testsuite/gcc.dg/gomp/pr27388-3.c b/gcc/testsuite/gcc.dg/gomp/pr27388-3.c index a6f4647aa5fbd6e6ddc603e1fa9b7df1a02605a9..2cddb23c7d8a8cf83b56aeb8f6143ff919fb3d06 100644 --- a/gcc/testsuite/gcc.dg/gomp/pr27388-3.c +++ b/gcc/testsuite/gcc.dg/gomp/pr27388-3.c @@ -19,5 +19,5 @@ foo (void) } } -/* { dg-final { scan-tree-dump-times "omp for\[^\\n\]*private" 0 "omplower" } } */ +/* { dg-final { scan-tree-dump-times "omp for\[^\\n\]*private" 2 "omplower" } } */ /* { dg-final { cleanup-tree-dump "omplower" } } */ diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 18e1bf7c43a055bf1c7818c438e475414d782e77..ad550e8fa33e1807c728405157f8a24e6149bf70 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,5 +1,9 @@ 2008-06-27 Jakub Jelinek <jakub@redhat.com> + * testsuite/libgomp.c/loop-10.c: New test. + * libgomp.c/loop-3.c (main): Add lastprivate clause. + * libgomp.c++/loop-6.C (main): Likewise. + PR debug/36617 * testsuite/libgomp.c/debug-1.c: New test. diff --git a/libgomp/testsuite/libgomp.c++/loop-6.C b/libgomp/testsuite/libgomp.c++/loop-6.C index fa26c6892cff218e447e1445b91ae381d674bb30..f4a6925a40c600b6189279c644a07323d904d049 100644 --- a/libgomp/testsuite/libgomp.c++/loop-6.C +++ b/libgomp/testsuite/libgomp.c++/loop-6.C @@ -8,10 +8,11 @@ static int test(void) return ++count > 0; } +int i; + int main() { - int i; - #pragma omp for + #pragma omp for lastprivate (i) for (i = 0; i < 10; ++i) { if (test()) diff --git a/libgomp/testsuite/libgomp.c/loop-10.c b/libgomp/testsuite/libgomp.c/loop-10.c new file mode 100644 index 0000000000000000000000000000000000000000..1b42c4bf126f250083d4dad58a02c6ec53110f8e --- /dev/null +++ b/libgomp/testsuite/libgomp.c/loop-10.c @@ -0,0 +1,30 @@ +extern void abort (void); + +int i = 8; + +int main (void) +{ + int j = 7, k = 0; + #pragma omp for + for (i = 0; i < 10; i++) + ; + #pragma omp for + for (j = 0; j < 10; j++) + ; + /* OpenMP 3.0 newly guarantees that the original list items can't + be shared with the privatized omp for iterators, even when + the original list items are already private. */ + if (i != 8 || j != 7) + abort (); + #pragma omp parallel private (i) reduction (+:k) + { + i = 6; + #pragma omp for + for (i = 0; i < 10; i++) + ; + k = (i != 6); + } + if (k) + abort (); + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/loop-3.c b/libgomp/testsuite/libgomp.c/loop-3.c index ba3ecdaca3af3cac779f2644eef5801a9cb85e13..f0f9b4705f91bf651fd4c5797c73da42c222ba18 100644 --- a/libgomp/testsuite/libgomp.c/loop-3.c +++ b/libgomp/testsuite/libgomp.c/loop-3.c @@ -8,10 +8,11 @@ static int test(void) return ++count > 0; } +int i; + int main() { - int i; - #pragma omp for + #pragma omp for lastprivate (i) for (i = 0; i < 10; ++i) { if (test())