Hi!

OpenMP 3.0 says that static variables that are declared in a scope inside
the construct are predetermined shared.  OpenMP 2.5 was silent about it.
I've asked on OpenMP forum about the local externs, if those should be
predetermined shared too, I'll drop the && !DECL_EXTERNAL (t).

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk
and 4.6.

2011-04-22  Jakub Jelinek  <ja...@redhat.com>

        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.

--- gcc/gimplify.c.jj   2011-04-18 11:28:05.000000000 +0200
+++ gcc/gimplify.c      2011-04-22 12:52:07.000000000 +0200
@@ -1144,7 +1144,7 @@ gimplify_bind_expr (tree *expr_p, gimple
          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))
--- gcc/testsuite/gcc.dg/gomp/pr48716.c.jj      2011-04-22 13:21:32.000000000 
+0200
+++ gcc/testsuite/gcc.dg/gomp/pr48716.c 2011-04-22 13:21:13.000000000 +0200
@@ -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++;
+  }
+}
--- gcc/testsuite/g++.dg/gomp/pr48716.C.jj      2011-04-22 13:21:49.000000000 
+0200
+++ gcc/testsuite/g++.dg/gomp/pr48716.C 2011-04-22 13:21:59.000000000 +0200
@@ -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++;
+  }
+}

        Jakub

Reply via email to