re PR c/48716 (gcc OpenMP static variable declared in scope inside construct is prede...
authorJakub Jelinek <jakub@redhat.com>
Fri, 22 Apr 2011 14:10:45 +0000 (16:10 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 22 Apr 2011 14:10:45 +0000 (16:10 +0200)
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
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr48716.C [new file with mode: 0644]
gcc/testsuite/gcc.dg/gomp/pr48716.c [new file with mode: 0644]

index 8a416a55acf4493222c182cf72b094b0f8b03eee..60b6662bd08ea5aead435046dc492b4b6566078c 100644 (file)
@@ -1,3 +1,9 @@
+2011-04-22  Jakub Jelinek  <jakub@redhat.com>
+
+       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  <mjambor@suse.cz>
 
        PR middle-end/48585
index f24bea2cb14dd9722beef71da3715aee4721cf7c..a554c20e76bafeb8c653b29e9245a79695a28dc2 100644 (file)
@@ -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))
index 95618277add100df3c476e56f164cc2a0b6ff6cd..cbdd47c35403e8268d1027129451865e85a0210a 100644 (file)
@@ -1,3 +1,9 @@
+2011-04-22  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/48716
+       * gcc.dg/gomp/pr48716.c: New test.
+       * g++.dg/gomp/pr48716.C: New test.
+
 2011-04-22  Alexander Monakov  <amonakov@ispras.ru>
 
        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 (file)
index 0000000..2dccad2
--- /dev/null
@@ -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 (file)
index 0000000..3496e2f
--- /dev/null
@@ -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++;
+  }
+}