From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 148923858C60 for ; Mon, 28 Feb 2022 16:00:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 148923858C60 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-451-iG8oLsDGPOCwiLbmF6D5pg-1; Mon, 28 Feb 2022 11:00:21 -0500 X-MC-Unique: iG8oLsDGPOCwiLbmF6D5pg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9335181CD1F; Mon, 28 Feb 2022 16:00:18 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.99]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 80B181078655; Mon, 28 Feb 2022 16:00:17 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 21SG0CjG2638909 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 28 Feb 2022 17:00:12 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 21SG09122638907; Mon, 28 Feb 2022 17:00:09 +0100 Date: Mon, 28 Feb 2022 17:00:09 +0100 From: Jakub Jelinek To: Mikael Morin Cc: Kwok Cheung Yeung , Tobias Burnus , gscfq@t-online.de, gcc-patches , fortran Subject: Re: [PATCH] openmp, fortran: Check that event handles passed to detach clauses are not arrays [PR104131] Message-ID: Reply-To: Jakub Jelinek References: <383792f1-a5c7-af10-c603-2f1332336648@codesourcery.com> <3c2d161f-481a-b223-a855-cadee01a5679@orange.fr> MIME-Version: 1.0 In-Reply-To: <3c2d161f-481a-b223-a855-cadee01a5679@orange.fr> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 16:00:29 -0000 On Mon, Feb 28, 2022 at 04:54:24PM +0100, Mikael Morin wrote: > Le 28/02/2022 à 15:27, Kwok Cheung Yeung a écrit : > > On 28/02/2022 2:07 pm, Jakub Jelinek wrote: > (...) > > > Don't we usually test instead || (*expr)->rank != 0 when testing for > > > scalars? > > > > (...) > > > > 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. > > > I can’t tell what openmp requires; it depends on your needs. > > Checking sym->as captures array variables which may include scalar > expressions (arr(10) is a scalar expression even if arr is an array > variable), while checking expr->rank only capture array expression, > including scalar variable with array subcomponent (scal%array_comp(:) is an > array expression, even if scal is a scalar variable). > > gfc_resolve_expr, through gfc_expression_rank takes care of properly setting > expr->rank. > If the check is done at resolution stage (somewhere in resolve_omp_clauses I > guess?), the rank should be set. > > I hope it helps. 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. Jakub