From patchwork Thu Jan 13 12:07:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 49964 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5C0BD3948819 for ; Thu, 13 Jan 2022 12:07:58 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa2.mentor.iphmx.com (esa2.mentor.iphmx.com [68.232.141.98]) by sourceware.org (Postfix) with ESMTPS id E4B213857C7C for ; Thu, 13 Jan 2022 12:07:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E4B213857C7C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: T3AHJMpFmYHrjGk+kO+0WUDePTUb9YmvOGwS3G6X8OLAqjCsI1r+JdhdBr7aF8tf47DhkGbcSY DZfQ9O+5ekJJGV7A4scBvm6FAnY25JnU9I0SQCTWVHA5eVzmxwoRfXj0oNiE9nH7Cf/JwsTP2I TlY9o24K7z1XEeicEKF57BgHzQDRf6dn2R5lW0d4tjSVdQXjtYfkvMy1JSZO9uN6dyOIKFLFIZ ibl9C1+mZPwsclA7uFwYCzkx+ch6HMpltP72PXt/QtaiGUH/8+2ZU1x6+h5SR9+TdB3pQ85mYr pAh9chIZ7FlM0H4jsMnhQwSa X-IronPort-AV: E=Sophos;i="5.88,286,1635235200"; d="scan'208,223";a="70718896" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa2.mentor.iphmx.com with ESMTP; 13 Jan 2022 04:07:39 -0800 IronPort-SDR: EODn2pP9SUFoQlpVh6CFRMEmVA6DkjpxHXqk8SXjVl2Tf1dz9Ov3OFvZGnYo/tdS4DxlLZCEh9 ipfcmltUH5pUKbbsc/sHRgRE5R2G2Ilrev7xNxIpdOQVmyoBrcUjoElpPen9tL3JZnspEPzyvu HQVNxHfTU+lKj98nYMk/BYdpxjfjnK3hMADmadh+8OqaGaEZSzjHiaS3gEp4QW2suPmHMbLQUb pfxFGFBhNh1vU8fdWL54Wm5d8eCFb4sOjslfBy3tQRg6s53JEGB/RD3xO+D5+2st6IrOFkr9Gw e3Y= From: Thomas Schwinge To: Subject: Merge 'c-c++-common/goacc/routine-6.c' into 'c-c++-common/goacc/routine-5.c', and document current C/C++ difference (was: [PATCH] openacc: Fix up C++ #pragma acc routine handling [PR101731]) In-Reply-To: <20211122150231.GP2646553@tucnak> References: <20211120083953.GZ2646553@tucnak> <87h7c4gs8p.fsf@euler.schwinge.homeip.net> <20211122150231.GP2646553@tucnak> User-Agent: Notmuch/0.29.3+94~g74c3f1b (https://notmuchmail.org) Emacs/27.1 (x86_64-pc-linux-gnu) Date: Thu, 13 Jan 2022 13:07:30 +0100 Message-ID: <87wnj3dekd.fsf@euler.schwinge.homeip.net> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jakub Jelinek , Tobias Burnus Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! On 2021-11-22T16:02:31+0100, Jakub Jelinek via Gcc-patches wrote: > On Mon, Nov 22, 2021 at 03:49:42PM +0100, Thomas Schwinge wrote: >> Then, regarding the user-visible behavior: >> >> > +#pragma acc routine /* { dg-error "not immediately followed by a single function declaration or definition" "" { target c++ } } */ >> > +int foo (int bar ()); >> >> So in C++ we now refuse, but in C we do accept this. I suppose I shall >> look into making C behave the same way -- unless there is a reason for >> the different behavior? And/or, is it actually is useful to allow such >> nested usage? Per its associated clauses, an OpenACC 'routine' directive >> really is meant to apply to one function only, in contrast to OpenMP >> 'target declare'. But the question is whether we should raise an error >> for the example above, or whether the 'routine' shall just apply to 'foo' >> but not 'bar', but without an error diagnostic? > > All I've verified is that our OpenMP code handles it the same way, Thanks for the explanation. Pushed to master branch commit 67fdcc8835665b5bc13652205e815e498d65c5a1 "Merge 'c-c++-common/goacc/routine-6.c' into 'c-c++-common/goacc/routine-5.c', and document current C/C++ difference", see attached. Grüße Thomas > i.e. > #pragma omp declare simd > int foo (int bar ()); > is accepted in C and rejected in C++. > I guess one question is to check if it is in both languages actually > the same thing. If we want to accept it in C++ and let the pragma > apply only to the outer declaration, I guess we'd need to temporarily > set to NULL parser->omp_declare_simd and parser->oacc_routine while > parsing the parameters of a function declaration or definition. > At least OpenMP is fairly fuzzy here, the reason we error on > #pragma omp declare simd > int foo (), i; > has been mainly some discussions in the lang committee and the fact > that it talks about a single declaration, not all affected declarations. > Whether int foo (int bar ()); should be in that light treated as two > function declarations or one with another one nested in it and irrelevant > for it is unclear. > > Jakub ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955 From 67fdcc8835665b5bc13652205e815e498d65c5a1 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Mon, 22 Nov 2021 16:09:09 +0100 Subject: [PATCH] Merge 'c-c++-common/goacc/routine-6.c' into 'c-c++-common/goacc/routine-5.c', and document current C/C++ difference gcc/testsuite/ * c-c++-common/goacc/routine-6.c: Merge into... * c-c++-common/goacc/routine-5.c: ... this, and document current C/C++ difference. --- gcc/testsuite/c-c++-common/goacc/routine-5.c | 8 ++++++++ gcc/testsuite/c-c++-common/goacc/routine-6.c | 4 ---- 2 files changed, 8 insertions(+), 4 deletions(-) delete mode 100644 gcc/testsuite/c-c++-common/goacc/routine-6.c diff --git a/gcc/testsuite/c-c++-common/goacc/routine-5.c b/gcc/testsuite/c-c++-common/goacc/routine-5.c index e3fbd6573b8..94678f2bf5b 100644 --- a/gcc/testsuite/c-c++-common/goacc/routine-5.c +++ b/gcc/testsuite/c-c++-common/goacc/routine-5.c @@ -94,6 +94,14 @@ typedef struct c_2 c_2; #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */ struct d_2 {} d_2; +/* PR c++/101731 */ +/* Regarding the current C/C++ difference, see + . */ +#pragma acc routine /* { dg-error "not immediately followed by a single function declaration or definition" "" { target c++ } } */ +int pr101731_foo (int pr101731_bar ()); +#pragma acc routine (pr101731_foo) vector /* { dg-error "has already been marked with an OpenACC 'routine' directive" "" { target c } } */ +#pragma acc routine (pr101731_bar) vector /* { dg-error "'pr101731_bar' has not been declared" } */ + #pragma acc routine /* { dg-error ".#pragma acc routine. not immediately followed by function declaration or definition" } */ #pragma acc routine int fn4 (void); diff --git a/gcc/testsuite/c-c++-common/goacc/routine-6.c b/gcc/testsuite/c-c++-common/goacc/routine-6.c deleted file mode 100644 index 0a231a015a7..00000000000 --- a/gcc/testsuite/c-c++-common/goacc/routine-6.c +++ /dev/null @@ -1,4 +0,0 @@ -/* PR c++/101731 */ - -#pragma acc routine /* { dg-error "not immediately followed by a single function declaration or definition" "" { target c++ } } */ -int foo (int bar ()); -- 2.34.1