From patchwork Tue Dec 19 11:20:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Schwinge X-Patchwork-Id: 82471 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 4E6B8385E454 for ; Tue, 19 Dec 2023 11:20:28 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id BCC4E3858C42 for ; Tue, 19 Dec 2023 11:20:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BCC4E3858C42 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BCC4E3858C42 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=68.232.137.252 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702984812; cv=none; b=KCQdyGuPxJ7xlXstTqjjArpYn+zgoMNnI/keTT38sn10+cgnwGsQeTdsCOYQGyAuHBmhDeDMIGZSmT6CHoq/LLWa8+HTqhehEojQuTBwg3CNEDHuh3s6+4gSr+TJ40cPZ3TM0vFZUt7aCIDT11LlIS2aC6aobuQPB+16OloVdYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702984812; c=relaxed/simple; bh=cX//D+r37gZuvJpnmMsqAE5a+Brofn39sfaMJbFcl1k=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=JN6Ze8hRChPaGAKl/l/aVFQljvMiNKH4weitX5vqFoUcnwEhSzG3lQ0Yurit1lakO1BmnARDCutkF8EOIMmXI7x//pNT7dlZY22JgCFujpk48CSkgkA3wuFYPaH6m282l0IIUg1a/pDbdKLipog6THmMArycQI0UvaoU4LmkcbM= ARC-Authentication-Results: i=1; server2.sourceware.org X-CSE-ConnectionGUID: hPYrZgZHRqK5KFLIGk/e7w== X-CSE-MsgGUID: kxLck7F/SyuWaNx5uWDvtw== X-IronPort-AV: E=Sophos;i="6.04,288,1695715200"; d="scan'208,223";a="25709917" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 19 Dec 2023 03:20:09 -0800 IronPort-SDR: aIN26T81MlAxrnLw6KV1i7HvvPldeezV78MPma6PC6/VZAk4egrxCieQrTQnb0fXKIjI+XuLB0 luLGFXI4J9rgGy0nt/bakKkvz5k3U1wy5aUY91IOHOL5Dr4qUqHenJznqwYW032fU/o60x6Xpz gDpQASNtlqMgTBkeS3B0II+EyNTMlrTRa8yeJYcePROMd7SlUOqJVhAObDqOk9hWLt7MxMDC3m 58zj5gEDHl3LNkwH576vXzbdNV/SlHKXXrWwdA/VcLdfW1jHFe7XjtxF5eFEZqQvtktg9iclCa 9Hs= From: Thomas Schwinge To: Subject: Unify OpenACC/C and C++ behavior re duplicate OpenACC 'declare' directives for 'extern' variables [PR90868] (was: [committed] [PR90868] Document status quo for duplicate OpenACC 'declare' directives for 'extern' variables) In-Reply-To: <874l4mh6oi.fsf@euler.schwinge.homeip.net> References: <874l4mh6oi.fsf@euler.schwinge.homeip.net> User-Agent: Notmuch/0.29.1+93~g67ed7df (https://notmuchmail.org) Emacs/27.1 (i686-pc-linux-gnu) Date: Tue, 19 Dec 2023 12:20:01 +0100 Message-ID: <87y1dqv3q6.fsf@dirichlet.schwinge.homeip.net> MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-14.mgc.mentorg.com (139.181.222.14) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Hi! On 2019-06-19T00:25:49+0200, I wrote: > This doesn't resolve PR90868, but at least in trunk r272445 we now > "Document status quo for duplicate OpenACC 'declare' directives for > 'extern' variables", see attached. > --- a/gcc/testsuite/c-c++-common/goacc/declare-1.c > +++ b/gcc/testsuite/c-c++-common/goacc/declare-1.c > +/* The same as 'f'. */ > + > +void > +f_2 (void) > +{ > +#ifndef __cplusplus > + /* TODO PR90868 > + > + C: "error: variable '[...]' used more than once with '#pragma acc declare'". */ > +#else > + extern int ve0; > +#pragma acc declare create(ve0) > /* The same as 'f' but everything contained in an OpenACC 'data' construct. */ > > void > @@ -115,7 +193,12 @@ f_data (void) > int va3; > # pragma acc declare device_resident(va3) > > -#if 0 /* TODO */ > +#if 0 > + /* TODO PR90868 > + > + C: "error: variable '[...]' used more than once with '#pragma acc declare'". > + C++: ICE during gimplification. */ > + > extern int ve0; > # pragma acc declare create(ve0) Pushed to master branch commit cf840a7f7c14242ab7018071310851486a557d4f "Unify OpenACC/C and C++ behavior re duplicate OpenACC 'declare' directives for 'extern' variables [PR90868]", see attached. Later we'll have to check how changes like commit 4e62aca0e0520e4ed2532f2d8153581190621c1a "c++: block-scope externs get an alias [PR95677,PR31775,PR95677]", commit db3d7270b42fe27fb05664c4fdf524ab7ad13a75 "openmp: Fix up declare target handling for vars with DECL_LOCAL_DECL_ALIAS [PR102640]" (and possibly others) actually apply to OpenACC 'declare'. Grüße Thomas ----------------- 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 cf840a7f7c14242ab7018071310851486a557d4f Mon Sep 17 00:00:00 2001 From: Thomas Schwinge Date: Mon, 18 Dec 2023 17:25:17 +0100 Subject: [PATCH] Unify OpenACC/C and C++ behavior re duplicate OpenACC 'declare' directives for 'extern' variables [PR90868] This likely still isn't what OpenACC actually intends (addressing that is for another day), but at least we now misbehave consistently for C and C++. PR c++/90868 gcc/cp/ * parser.cc (cp_parser_oacc_declare): For "more than once", check the DECL that we're actually setting the attribute on. gcc/testsuite/ * c-c++-common/goacc/declare-1.c: Adjust. * c-c++-common/goacc/declare-2.c: Likewise. --- gcc/cp/parser.cc | 23 +++++++------ gcc/testsuite/c-c++-common/goacc/declare-1.c | 9 +++--- gcc/testsuite/c-c++-common/goacc/declare-2.c | 34 ++++++++------------ 3 files changed, 29 insertions(+), 37 deletions(-) diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index e4fbab1bab5..1e2d520345b 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -46962,20 +46962,8 @@ cp_parser_oacc_declare (cp_parser *parser, cp_token *pragma_tok) continue; } - if (lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)) - || lookup_attribute ("omp declare target link", - DECL_ATTRIBUTES (decl))) - { - error_at (loc, "variable %qD used more than once with " - "%<#pragma acc declare%>", decl); - error = true; - continue; - } - if (!error) { - tree id; - if (DECL_LOCAL_DECL_P (decl)) /* We need to mark the aliased decl, as that is the entity that is being referred to. This won't work for @@ -46987,6 +46975,17 @@ cp_parser_oacc_declare (cp_parser *parser, cp_token *pragma_tok) if (alias != error_mark_node) decl = alias; + if (lookup_attribute ("omp declare target", DECL_ATTRIBUTES (decl)) + || lookup_attribute ("omp declare target link", + DECL_ATTRIBUTES (decl))) + { + error_at (loc, "variable %qD used more than once with " + "%<#pragma acc declare%>", decl); + error = true; + continue; + } + + tree id; if (OMP_CLAUSE_MAP_KIND (t) == GOMP_MAP_LINK) id = get_identifier ("omp declare target link"); else diff --git a/gcc/testsuite/c-c++-common/goacc/declare-1.c b/gcc/testsuite/c-c++-common/goacc/declare-1.c index 46ee01b6759..808dc2ac818 100644 --- a/gcc/testsuite/c-c++-common/goacc/declare-1.c +++ b/gcc/testsuite/c-c++-common/goacc/declare-1.c @@ -113,11 +113,11 @@ f_2 (void) int va3; #pragma acc declare device_resident(va3) -#ifndef __cplusplus +#if 0 /* TODO PR90868 - C: "error: variable '[...]' used more than once with '#pragma acc declare'". */ -#else + "error: variable '[...]' used more than once with '#pragma acc declare'". */ + extern int ve0; #pragma acc declare create(ve0) @@ -196,8 +196,7 @@ f_data (void) #if 0 /* TODO PR90868 - C: "error: variable '[...]' used more than once with '#pragma acc declare'". - C++: ICE during gimplification. */ + "error: variable '[...]' used more than once with '#pragma acc declare'". */ extern int ve0; # pragma acc declare create(ve0) diff --git a/gcc/testsuite/c-c++-common/goacc/declare-2.c b/gcc/testsuite/c-c++-common/goacc/declare-2.c index e2e22be57e9..35e45004561 100644 --- a/gcc/testsuite/c-c++-common/goacc/declare-2.c +++ b/gcc/testsuite/c-c++-common/goacc/declare-2.c @@ -137,61 +137,55 @@ void f_pr90868_2 (void) { extern int we0; -#pragma acc declare create(we0) /* { dg-error "variable 'we0' used more than once with '#pragma acc declare'" "" { target c } } */ +#pragma acc declare create(we0) /* { dg-error "variable 'we0' used more than once with '#pragma acc declare'" } */ extern int we1; -#pragma acc declare copyin(we1) /* { dg-error "variable 'we1' used more than once with '#pragma acc declare'" "" { target c } } */ +#pragma acc declare copyin(we1) /* { dg-error "variable 'we1' used more than once with '#pragma acc declare'" } */ extern int *we2; -#pragma acc declare deviceptr(we2) /* { dg-error "variable 'we2' used more than once with '#pragma acc declare'" "" { target c } } */ +#pragma acc declare deviceptr(we2) /* { dg-error "variable 'we2' used more than once with '#pragma acc declare'" } */ extern int we3; -#pragma acc declare device_resident(we3) /* { dg-error "variable 'we3' used more than once with '#pragma acc declare'" "" { target c } } */ +#pragma acc declare device_resident(we3) /* { dg-error "variable 'we3' used more than once with '#pragma acc declare'" } */ extern int we4; -#pragma acc declare link(we4) /* { dg-error "variable 'we4' used more than once with '#pragma acc declare'" "" { target c } } */ +#pragma acc declare link(we4) /* { dg-error "variable 'we4' used more than once with '#pragma acc declare'" } */ extern int we5; -#pragma acc declare present_or_copyin(we5) /* { dg-error "variable 'we5' used more than once with '#pragma acc declare'" "" { target c } } */ +#pragma acc declare present_or_copyin(we5) /* { dg-error "variable 'we5' used more than once with '#pragma acc declare'" } */ extern int we6; -#pragma acc declare present_or_create(we6) /* { dg-error "variable 'we6' used more than once with '#pragma acc declare'" "" { target c } } */ +#pragma acc declare present_or_create(we6) /* { dg-error "variable 'we6' used more than once with '#pragma acc declare'" } */ } /* The same as 'f_pr90868' but everything contained in an OpenACC 'data' construct. */ -#ifdef __cplusplus -/* TODO PR90868 - - C++: ICE during gimplification. */ -#else void f_pr90868_data (void) { #pragma acc data { extern int we0; -# pragma acc declare create(we0) /* { dg-error "variable 'we0' used more than once with '#pragma acc declare'" "" { target c } } */ +# pragma acc declare create(we0) /* { dg-error "variable 'we0' used more than once with '#pragma acc declare'" } */ extern int we1; -# pragma acc declare copyin(we1) /* { dg-error "variable 'we1' used more than once with '#pragma acc declare'" "" { target c } } */ +# pragma acc declare copyin(we1) /* { dg-error "variable 'we1' used more than once with '#pragma acc declare'" } */ extern int *we2; -# pragma acc declare deviceptr(we2) /* { dg-error "variable 'we2' used more than once with '#pragma acc declare'" "" { target c } } */ +# pragma acc declare deviceptr(we2) /* { dg-error "variable 'we2' used more than once with '#pragma acc declare'" } */ extern int we3; -# pragma acc declare device_resident(we3) /* { dg-error "variable 'we3' used more than once with '#pragma acc declare'" "" { target c } } */ +# pragma acc declare device_resident(we3) /* { dg-error "variable 'we3' used more than once with '#pragma acc declare'" } */ extern int we4; -# pragma acc declare link(we4) /* { dg-error "variable 'we4' used more than once with '#pragma acc declare'" "" { target c } } */ +# pragma acc declare link(we4) /* { dg-error "variable 'we4' used more than once with '#pragma acc declare'" } */ extern int we5; -# pragma acc declare present_or_copyin(we5) /* { dg-error "variable 'we5' used more than once with '#pragma acc declare'" "" { target c } } */ +# pragma acc declare present_or_copyin(we5) /* { dg-error "variable 'we5' used more than once with '#pragma acc declare'" } */ extern int we6; -# pragma acc declare present_or_create(we6) /* { dg-error "variable 'we6' used more than once with '#pragma acc declare'" "" { target c } } */ +# pragma acc declare present_or_create(we6) /* { dg-error "variable 'we6' used more than once with '#pragma acc declare'" } */ } } -#endif -- 2.34.1