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 D776F3858C60; Mon, 28 Feb 2022 14:28:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D776F3858C60 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,142,1643702400"; d="scan'208";a="72524768" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa2.mentor.iphmx.com with ESMTP; 28 Feb 2022 06:28:02 -0800 IronPort-SDR: OP2g//u65vLD1JBgDsiM2OROjDbYKcfVhBMtSdUUgCm8UNzRXc0M2czj2w8/yAczV7YR/1WDfL Vat/WE5UGEDTRlKw2L7vGq4Ow7wM2LtB/fCqW3q13k+TV4F4RhN98aZrAXArlnfunJRTMFbK8x nnFaaQ0cmhL50auMZWoGVHvYeXdD203dB/Ysjr4PrYVh+giBBKOYmOMdlHaSAFXOnSWu6Wgh11 zmzJ9tqjzUKFlihfJosxa3VgX5OJoertusuSY7fFRG82ZQKjzhEx7ffIP2A8hXAiazSmpy5LIS U3E= Message-ID: <383792f1-a5c7-af10-c603-2f1332336648@codesourcery.com> Date: Mon, 28 Feb 2022 14:27:02 +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 , Tobias Burnus CC: gcc-patches , fortran , References: 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-14.mgc.mentorg.com (139.181.222.14) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, 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=ham 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 14:28:05 -0000 On 28/02/2022 2:07 pm, Jakub Jelinek wrote: > On Mon, Feb 28, 2022 at 02:01:03PM +0000, Kwok Cheung Yeung wrote: >> diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc >> index 19142c4d8d0..50a1c476009 100644 >> --- a/gcc/fortran/openmp.cc >> +++ b/gcc/fortran/openmp.cc >> @@ -531,9 +531,10 @@ gfc_match_omp_detach (gfc_expr **expr) >> if (gfc_match_variable (expr, 0) != MATCH_YES) >> goto syntax_error; >> >> - if ((*expr)->ts.type != BT_INTEGER || (*expr)->ts.kind != gfc_c_intptr_kind) >> + if ((*expr)->ts.type != BT_INTEGER || (*expr)->ts.kind != gfc_c_intptr_kind >> + || (*expr)->symtree->n.sym->as) > > Don't we usually test instead || (*expr)->rank != 0 when testing for > scalars? > > Jakub > If I run GCC in GDB on the pr104131.f90 testcase and inspect the expr, I get: 534 if ((*expr)->ts.type != BT_INTEGER || (*expr)->ts.kind != gfc_c_intptr_kind (gdb) p **expr $2 = {expr_type = EXPR_VARIABLE, ts = {type = BT_INTEGER, kind = 8, u = {derived = 0x0, cl = 0x0, pad = 0}, interface = 0x0, is_c_interop = 1, is_iso_c = 0, f90_type = BT_INTEGER, deferred = false, interop_kind = 0x2e3fb80}, rank = 0, shape = 0x0, symtree = 0x2e3ffe0, ref = 0x2e3e600, where = { ... So (*expr)->rank is 0 here even with an array. I'm not sure why - is rank updated later, or did we forget to call something on the event handle expression? Testing against n->sym->as for an array check has been used elsewhere in openmp.cc, to prevent reductions against arrays in OpenACC in resolve_omp_clauses. Kwok