From patchwork Fri Apr 22 14:17:12 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 92540 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id E26351007DC for ; Sat, 23 Apr 2011 00:17:35 +1000 (EST) Received: (qmail 14156 invoked by alias); 22 Apr 2011 14:17:31 -0000 Received: (qmail 14145 invoked by uid 22791); 22 Apr 2011 14:17:29 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 22 Apr 2011 14:17:15 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p3MEHDnK015380 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 22 Apr 2011 10:17:13 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p3MEHD0m002603 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 22 Apr 2011 10:17:13 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p3MEHCAX010009 for ; Fri, 22 Apr 2011 16:17:12 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p3MEHCUL010007 for gcc-patches@gcc.gnu.org; Fri, 22 Apr 2011 16:17:12 +0200 Date: Fri, 22 Apr 2011 16:17:12 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] Fix default(none) diagnostic about block local statics (PR c/48716) Message-ID: <20110422141712.GW17079@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 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. Jakub --- 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++; + } +}