* 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)
2019-06-18 22:26 [committed] [PR90868] Document status quo for duplicate OpenACC 'declare' directives for 'extern' variables Thomas Schwinge
@ 2023-12-19 11:20 ` Thomas Schwinge
0 siblings, 0 replies; 2+ messages in thread
From: Thomas Schwinge @ 2023-12-19 11:20 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1933 bytes --]
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
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Unify-OpenACC-C-and-C-behavior-re-duplicate-OpenACC-.patch --]
[-- Type: text/x-diff, Size: 7716 bytes --]
From cf840a7f7c14242ab7018071310851486a557d4f Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
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
^ permalink raw reply [flat|nested] 2+ messages in thread