From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 53F33394504F for ; Thu, 12 Mar 2020 14:43:09 +0000 (GMT) IronPort-SDR: VdUuRwBNiSOjVv9kWVu/j81p9rgCJEzCY4F8T54WQQUXHVHxASwZpE9/1rjemwCW4SqKDgoGpz FWHkKSO3bgmz6cgYzWIV+HaDXsK8/touR6ipLtUUN6I1k6HNcnxXXAU4IRzCJc0Ye3pSjGk6OC qWoJd29kZoqkcIqQJ6eNnrDfyKvOqn+L4T8+mW4xN6lndG1hB9OfWS3N/UST4oNJdUdEDVQgRX 1YVWivlt2M57L2lUuLktDVxsDy/S+5EepGmKYEUlUCXZvRddEIbBq2NM91/bXoREw2KgkfXlgi 2qE= X-URL-LookUp-ScanningError: 1 X-IronPort-AV: E=Sophos;i="5.70,545,1574150400"; d="scan'208";a="48616678" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 12 Mar 2020 06:43:08 -0800 IronPort-SDR: w9btTkSzDPMNs/K1/+/38FUhg0LfunKzJs8pyadCzq+ZNvoFVvv450WBueSl0YlYszSQFOBDGu NhTytfrgo8aaIPY8W78GSgPyRwxwpIPgBrYZHCRCqsX/Bot2NWhZ7cSmyqEkPPDOeZcozJIRW1 y4d/trzQvRLAXysTYasMZmmaWkYyzMGRB0GbnL4S8aFGy9LEfde7JHOKicmJqdTFqlDfMngIWi VcwZWwghmAFDm1BQN4iEmUdM9XQu4oIwLdjZ0ucVGj1oF1tcH+gFV/GPjvXwM/bM+Q35F+OWvf JbY= From: Frederik Harwath To: Tobias Burnus , gcc-patches , Thomas Schwinge Subject: Re: [C/C++, OpenACC] Reject vars of different scope in acc declare (PR94120) In-Reply-To: <0e98c5c9-7536-e11f-c42e-4e8060b147a5@codesourcery.com> References: <0e98c5c9-7536-e11f-c42e-4e8060b147a5@codesourcery.com> Date: Thu, 12 Mar 2020 15:43:03 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-02.mgc.mentorg.com (139.181.222.2) To SVR-IES-MBX-03.mgc.mentorg.com (139.181.222.3) X-Spam-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, HEADER_FROM_DIFFERENT_DOMAINS, SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , X-List-Received-Date: Thu, 12 Mar 2020 14:43:10 -0000 Tobias Burnus writes: Hi Tobias, > Fortran patch: https://gcc.gnu.org/pipermail/gcc-patches/current/541774.h= tml > > "A declare directive must be in the same scope > as the declaration of any var that appears in > the data clauses of the directive." > > ("A declare directive is used [=E2=80=A6] following a variable > declaration in C or C++".) > > NOTE for C++: This patch assumes that variables in a namespace > are handled in the same way as those which are at > global (namespace) scope; however, the OpenACC specification's > wording currently is "In C or C++ global scope, only =E2=80=A6". > Hence, one can argue about this part of the patch; but as > it fixes an ICE and is a very sensible extension =E2=80=93 the other > option is to reject it =E2=80=93 I believe it is fine. > (On the OpenACC side, this is now Issue 288.) Sounds reasonable to me. > +bool > +c_check_oacc_same_scope (tree decl) > +{ > + struct c_binding *b =3D I_SYMBOL_BINDING (DECL_NAME (decl)); > + return b !=3D NULL && B_IN_CURRENT_SCOPE (b); > +} Is the function really specific to OpenACC? If not, then "_oacc" could be dropped from its name. How about "c_check_current_scope"? > diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c > index 24f71671469..8f09eb0d375 100644 > --- a/gcc/cp/parser.c > +++ b/gcc/cp/parser.c > [...] > - if (global_bindings_p ()) > + if (current_binding_level->kind =3D=3D sk_namespace) > [...] > - if (error || global_bindings_p ()) > + if (error || current_binding_level->kind =3D=3D sk_namespace) > return NULL_TREE; So - just to be sure - the new namespace condition subsumes the old "global_bindings_p" condition because the global scope is also a namespace, right? Yes, now I see that you have a test case that demonstrates that the declare directive still works for global variables with those changes. > diff --git a/gcc/testsuite/g++.dg/declare-pr94120.C b/gcc/testsuite/g++.d= g/declare-pr94120.C > new file mode 100644 > index 00000000000..8515c4ff875 > --- /dev/null > +++ b/gcc/testsuite/g++.dg/declare-pr94120.C > @@ -0,0 +1,30 @@ > +/* { dg-do compile } */ > + > +/* PR middle-end/94120 */ > + > +int b[8]; > +#pragma acc declare create (b) Looks good to me. Frederik ----------------- Mentor Graphics (Deutschland) GmbH, Arnulfstra=C3=9Fe 201, 80634 M=C3=BCnch= en / Germany Registergericht M=C3=BCnchen HRB 106955, Gesch=C3=A4ftsf=C3=BChrer: Thomas = Heurung, Alexander Walter