public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Fix default(none) diagnostic about block local statics (PR c/48716)
@ 2011-04-22 14:50 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2011-04-22 14:50 UTC (permalink / raw)
  To: gcc-patches

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  <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.

	* 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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-04-22 14:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-22 14:50 [committed] Fix default(none) diagnostic about block local statics (PR c/48716) Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).