From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id 7E4863858D20; Mon, 28 Feb 2022 18:38:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7E4863858D20 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,144,1643702400"; d="scan'208";a="72510255" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 28 Feb 2022 10:38:55 -0800 IronPort-SDR: AHAs8mgVaDv2yaL12wkIKRj/KdNd9MLYt/s8lWFeJaZ6uikCTles0mqTKaetAf/pOHWUIwna0A JcVKoFkQ92ICW+woMMK3k3V0GJd2ipamX5EOSzY4qTBD4pluMfuTkgLRzlKZpbyifZnhxJPKa8 ak7qm/OKtYqAF/vlpjbs98kBNXT9ckI5xD7CRLlbkDu1GmRn4olZjMoPs0d9GNHm0Z61b2fsR1 kNGnuN5QI6LUVOW8xSa99mdXQ+DeWccHemto60avgB5TT73RK/4DnoWkoHbEcPcOk6jBCYwSHw OlE= Message-ID: Date: Mon, 28 Feb 2022 18:38:48 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1 From: Kwok Cheung Yeung Subject: Re: [PATCH] openmp, fortran: Check that event handles passed to detach clauses are not arrays [PR104131] To: Jakub Jelinek , Mikael Morin CC: Tobias Burnus , , 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> In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-06.mgc.mentorg.com (139.181.222.6) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, 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: Mon, 28 Feb 2022 18:38:57 -0000 On 28/02/2022 5:37 pm, Jakub Jelinek wrote: > On Mon, Feb 28, 2022 at 06:33:15PM +0100, Mikael Morin wrote: >>> It is true that the spots I saw in fortran/openmp.cc that test rank look >>> like: >>> if (!gfc_resolve_expr (el->expr) >>> || el->expr->ts.type != BT_INTEGER || el->expr->rank != 0) >>> etc., so probably !gfc_resolve_expr call is missing. >>> >> As long as the expression is expected to not be a (contained) function call, >> I think it should work. >> >> In the general case non-syntaxic errors are preferably checked and reported >> later at resolution stage, where contained functions are known. > > Oh, I've missed that it is done during parsing and not during resolution. > That !gfc_resolve_expr call and the checking if it is BT_INTEGER etc. > should be certainly moved to resolve_omp_clauses. > Calling gfc_resolve_expr does not work to update the rank when called from gfc_match_omp_detach: (gdb) p *e->ref $3 = {type = REF_ARRAY, u = {ar = {type = AR_ELEMENT, dimen = 0, codimen = 1, in_allocate = false, team = 0x0, stat = 0x0, where = {nextc = 0x2e532d8, lb = 0x2e53260}, as = 0x2e04110, c_where = {{nextc = 0x0, lb = 0x0} }, start = {0x0 }, end = {0x0 }, stride = {0x0 }, dimen_type = {DIMEN_THIS_IMAGE, 0 }}, c = {component = 0x2, sym = 0x1}, ss = {start = 0x2, end = 0x1, length = 0x0}, i = INQUIRY_KIND}, next = 0x0} In gfc_expression_rank, e->ref is non-NULL, so e->rank is not set from the symtree. It then iterates through the ref elements - ref->type == REF_ARRAY and ref->u.ar.type == AR_ELEMENT, so e->rank remains at 0. I'll move the check to resolve_omp_clauses and see if it works there. Thanks Kwok