From 144f4153e89ec081e3607c97b4d76bcfc06bba19 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 22 Apr 2011 16:10:45 +0200 Subject: [PATCH] re PR c/48716 (gcc OpenMP static variable declared in scope inside construct is predetermined shared) PR c/48716 * gimplify.c (gimplify_bind_expr): Mark as GOVD_LOCAL also TREE_STATIC variables declared inside of some OpenMP construct. * gcc.dg/gomp/pr48716.c: New test. * g++.dg/gomp/pr48716.C: New test. From-SVN: r172859 --- gcc/ChangeLog | 6 ++++++ gcc/gimplify.c | 2 +- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/g++.dg/gomp/pr48716.C | 24 ++++++++++++++++++++++++ gcc/testsuite/gcc.dg/gomp/pr48716.c | 24 ++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/gomp/pr48716.C create mode 100644 gcc/testsuite/gcc.dg/gomp/pr48716.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8a416a55acf..60b6662bd08 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-04-22 Jakub Jelinek + + PR c/48716 + * gimplify.c (gimplify_bind_expr): Mark as GOVD_LOCAL also + TREE_STATIC variables declared inside of some OpenMP construct. + 2011-04-22 Martin Jambor PR middle-end/48585 diff --git a/gcc/gimplify.c b/gcc/gimplify.c index f24bea2cb14..a554c20e76b 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1144,7 +1144,7 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p) struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp; /* Mark variable as local. */ - if (ctx && !is_global_var (t) + if (ctx && !DECL_EXTERNAL (t) && (! DECL_SEEN_IN_BIND_EXPR_P (t) || splay_tree_lookup (ctx->variables, (splay_tree_key) t) == NULL)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 95618277add..cbdd47c3540 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2011-04-22 Jakub Jelinek + + PR c/48716 + * gcc.dg/gomp/pr48716.c: New test. + * g++.dg/gomp/pr48716.C: New test. + 2011-04-22 Alexander Monakov PR c/36750 diff --git a/gcc/testsuite/g++.dg/gomp/pr48716.C b/gcc/testsuite/g++.dg/gomp/pr48716.C new file mode 100644 index 00000000000..2dccad2d90a --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr48716.C @@ -0,0 +1,24 @@ +// PR c/48716 +// { dg-do compile } +// { dg-options "-fopenmp" } + +int +main (void) +{ + #pragma omp parallel default(none) + { + static int s; + int t = 0; + #pragma omp atomic + s++; + t++; + } + #pragma omp task default(none) + { + static int s; + int t = 0; + #pragma omp atomic + s++; + t++; + } +} diff --git a/gcc/testsuite/gcc.dg/gomp/pr48716.c b/gcc/testsuite/gcc.dg/gomp/pr48716.c new file mode 100644 index 00000000000..3496e2f0227 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/pr48716.c @@ -0,0 +1,24 @@ +/* PR c/48716 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +int +main (void) +{ + #pragma omp parallel default(none) + { + static int s; + int t = 0; + #pragma omp atomic + s++; + t++; + } + #pragma omp task default(none) + { + static int s; + int t = 0; + #pragma omp atomic + s++; + t++; + } +} -- 2.30.2