From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id 1C2033858C78; Tue, 1 Mar 2022 07:59:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1C2033858C78 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.90,145,1643702400"; d="scan'208";a="72569888" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 28 Feb 2022 23:59:01 -0800 IronPort-SDR: p+rFdWasX+kxj+W0Gw3W42iRXwhxF0OqEDvqqUszQJMnOT4KQQvsvBp/xpb21Sx8Ubvm2IA+9i PRSzHBrERUh4hlqkF6WWY2dh+kvmtpha6znuDdbZ5Ly8inOY5cuQWM3T81If8uJTmFpKZBhdIc GdoBKfx6Uld6/kO+1zHe3S+GxHtl1ev0P/hHFP+zxOz/R1ECxGjZrFWVrvGeKWobIU6d/CqYk7 0rb/bkILJ2vPFoOa6wFgCaR3jkkpBLHVWEN9r/TfZaKcV7sCAx2Cxm/r4UCx59CvuiJgzyMeMM h7c= Message-ID: <65456330-dc81-0647-3bdb-6d409554136d@codesourcery.com> Date: Tue, 1 Mar 2022 08:58:54 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 Subject: Re: [PATCH] openmp, fortran: Check that event handles passed to detach clauses are not arrays [PR104131] Content-Language: en-US To: Jakub Jelinek , Mikael Morin CC: , Kwok Cheung Yeung , gcc-patches , fortran References: <383792f1-a5c7-af10-c603-2f1332336648@codesourcery.com> <3c2d161f-481a-b223-a855-cadee01a5679@orange.fr> <8981ebb8-7b8e-19d7-a3b3-ef5fce239c53@orange.fr> <907e1f89-4534-75e4-fdb8-a11da280e3d1@orange.fr> From: Tobias Burnus In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable 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=-5.5 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Tue, 01 Mar 2022 07:59:04 -0000 On 28.02.22 22:37, Jakub Jelinek via Fortran wrote: > On Mon, Feb 28, 2022 at 09:45:10PM +0100, Mikael Morin wrote: >> Lesson learned today: expressions don=E2=80=99t have a corank. >> Does pr104131-2.f90 really need to be rejected? In my reading of the spec, pr104131-2.f90 is _valid_ (in newer OMP). At least that's implied by the spec as quoted by Jakub: > OpenMP 5.2 says that detach clause should be treated as if it appears on = a > firstprivate clause and for the privatization clauses says: > "A private variable must not be coindexed or appear as an actual argument= to a procedure where > the corresponding dummy argument is a coarray." > 5.1 had the same restriction. +++ b/gcc/testsuite/gfortran.dg/gomp/pr104131-2.f90 ... + integer (kind=3Domp_event_handle_kind) :: x[*] + !$omp task detach (x) Here, 'x' is a coarray =E2=80=93 but refers to the local variable on this i= mage. But the following is invalid as it is coindexed: !$omp task detach (x[3]) where x[3] means that the value from 'x' on image 3 should be used. The wording actually also permits array sections. But contrary to coarrays, (which are odd but otherwise fine), I think it does not really make sense to have arrays and array sections here. (Do we need/want to get this clarified/changed in spec?) But from the wording of the spec, also the first testcase seems to be valid= . * * * >> A variable that is part of another variable (as an array element or a >> structure element) cannot appear in a detach clause. > which tells that the check should be on expr->ref instead of > expr->sym->as or expr->rank. I think looking at the "sym" is fine when matching the expression via gfc_match_omp_variable_list with allow_derived=3Dfalse (default). As then there cannot be derived-type components. Additionally, expr->rank > 0 rules out arrays/array sections but permits array elements while sym->addr.dimension also rules out array elements. BTW: after resolving a variable, expr->ref always exists for arrays =E2=80=93 either to select an element or array section or otherwise, there is an AR_FULL for a whole array. Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955