From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 9DD7F387084E; Wed, 10 Mar 2021 14:20:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9DD7F387084E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=mentor.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Tobias_Burnus@mentor.com IronPort-SDR: zWitig/Ztk3PqTqv/MIUqXXscxJMN6usLbwSw1kdbUoReltGreEXqNU5llpKqPrM76IfNNzw7T oZ0y6a5QyBtUDeGigA1p+J92ETyv87ft7VpluKDRpimtTtFRGwbzhaLPcL6NcozcVENJ07oH48 +qiojgCw+mzPM3ZmJLLSZwyW5ONGvYuxcU66o8GvTb4bqZ9Jyin2E/PHIuoFB08oNi74DBn3K4 pprBjmtWzQHDYY6TnFIBNiwJgMRm/FZkeir9Pm66aawe5wS23yRHtl2cqvyEJMk3KFYmW5mclj Axk= X-IronPort-AV: E=Sophos;i="5.81,237,1610438400"; d="diff'?scan'208";a="61278739" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 10 Mar 2021 06:20:56 -0800 IronPort-SDR: MydENMHxy6tPpSJi/kxiaQhmXjTtAGXr2T3Oj92K2rylfyQaOfr8rWo/VUXI8ZPwjbOQi5173C kA+gmN+qBje9RBsdbkSAeGgtj3CQI18Uh/E8E3Si82VII2COkShCuQozQc00E3B8d4so9EtuJk aIruOt+a6AVa52juWyUhIh681WWEUHzbpU134lCT4RKUQ2A6hDRJpBCcswe1DF7JWH0D1Ng6ZQ NZGq9qKDq4B4I+Mc3fVj2Zfiv7dBpZDg3O1L8o/WdxxxcTNwaVPFGMG5xumulpRW23ZpdejULc a3M= To: gcc-patches , fortran , Jakub Jelinek From: Tobias Burnus Subject: [Patch] Fortran/OpenMP: Accept implicit-save DATA vars for threadprivate [PR99514] Message-ID: <6de1fb7c-eeb7-e361-5494-a0bac24b65a7@mentor.com> Date: Wed, 10 Mar 2021 15:20:51 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------11EFA5707A38D99920B9E608" Content-Language: en-US X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Mar 2021 14:20:59 -0000 --------------11EFA5707A38D99920B9E608 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: quoted-printable If a variable appears in DATA, the following applies: F2018: 8.6.7 DATA statement "Except for variables in named common blocks, a named variable has the SAVE attribute if any part of it is initialized in a DATA statement, and this may be confirmed by explicit specification." The attached testcase was rejected as the implicit save was not honored. There is no need to distinguish between SAVE and COMMON as common was/is already accepted. The code used only '&&' conditions without a '!' before the '('. Thus, there is no need to indent half of the conditions ... OK for mainline? Tobias ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 M=C3=BCnchen R= egistergericht M=C3=BCnchen HRB 106955, Gesch=C3=A4ftsf=C3=BChrer: Thomas H= eurung, Frank Th=C3=BCrauf --------------11EFA5707A38D99920B9E608 Content-Type: text/x-patch; charset="UTF-8"; name="omp-threadprivate.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="omp-threadprivate.diff" Fortran/OpenMP: Accept implicit-save DATA vars for threadprivate [PR99514] gcc/fortran/ChangeLog: PR fortran/99514 * resolve.c (resolve_symbol): Accept vars which are in DATA and hence (either) implicit SAVE (or in common). gcc/testsuite/ChangeLog: PR fortran/99514 * gfortran.dg/gomp/threadprivate-1.f90: New test. gcc/fortran/resolve.c | 10 +++++----- gcc/testsuite/gfortran.dg/gomp/threadprivate-1.f90 | 11 +++++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 2a91ae743ea..32015c21efc 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -16024,12 +16024,12 @@ resolve_symbol (gfc_symbol *sym) } /* Check threadprivate restrictions. */ - if (sym->attr.threadprivate && !sym->attr.save + if (sym->attr.threadprivate + && !(sym->attr.save || sym->attr.data || sym->attr.in_common) && !(sym->ns->save_all && !sym->attr.automatic) - && (!sym->attr.in_common - && sym->module == NULL - && (sym->ns->proc_name == NULL - || sym->ns->proc_name->attr.flavor != FL_MODULE))) + && sym->module == NULL + && (sym->ns->proc_name == NULL + || sym->ns->proc_name->attr.flavor != FL_MODULE)) gfc_error ("Threadprivate at %L isn't SAVEd", &sym->declared_at); /* Check omp declare target restrictions. */ diff --git a/gcc/testsuite/gfortran.dg/gomp/threadprivate-1.f90 b/gcc/testsuite/gfortran.dg/gomp/threadprivate-1.f90 new file mode 100644 index 00000000000..59656c2b18d --- /dev/null +++ b/gcc/testsuite/gfortran.dg/gomp/threadprivate-1.f90 @@ -0,0 +1,11 @@ +! PR fortran/99514 +! +! NTest in DATA is implicitly SAVE, unless in COMMON +! Was failing before as the implicit SAVE was not +! honoured by the threadprivate check. +! + +program main + DATA NTest /1/ + !$omp threadprivate(Ntest) +end program main --------------11EFA5707A38D99920B9E608--