From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id CAA553854146; Tue, 5 Jul 2022 08:11:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CAA553854146 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Tobias Burnus To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-12] openmp: Adjust diagnostics about same variable in link and to/enter clauses X-Act-Checkin: gcc X-Git-Author: Jakub Jelinek X-Git-Refname: refs/heads/devel/omp/gcc-12 X-Git-Oldrev: d23aea91c1c5b4aea2af90634cf653cf7f12d720 X-Git-Newrev: 4c2a8e5a3e7eb64f21150e418841f52e9d4aeaed Message-Id: <20220705081103.CAA553854146@sourceware.org> Date: Tue, 5 Jul 2022 08:11:03 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Jul 2022 08:11:03 -0000 https://gcc.gnu.org/g:4c2a8e5a3e7eb64f21150e418841f52e9d4aeaed commit 4c2a8e5a3e7eb64f21150e418841f52e9d4aeaed Author: Jakub Jelinek Date: Tue Jul 5 09:29:23 2022 +0200 openmp: Adjust diagnostics about same variable in link and to/enter clauses On Fri, May 27, 2022 at 04:52:17PM +0200, Tobias Burnus wrote: > The 'TO'/'ENTER' usage is first stored in a linked list – and > then as attribute to the symbol. I am not sure how to handle it best. This reminds me I've left the C/C++ FE diagnostics about mixing link and to/enter on the same variable in separate directives as is, so it always talked about mixing link and to clauses. This patch adjusts it, so that if link is first, it talks about the clause actually used and if link is later, uses to or enter together in the wording. 2022-05-28 Jakub Jelinek gcc/c/ * c-parser.cc (c_parser_omp_declare_target): If OMP_CLAUSE_LINK was seen first, use "%" or "%" depending on OMP_CLAUSE_ENTER_TO of the current clause, otherwise use "% or %" wording. gcc/cp/ * parser.cc (handle_omp_declare_target_clause): If OMP_CLAUSE_LINK was seen first, use "%" or "%" depending on OMP_CLAUSE_ENTER_TO of the current clause, otherwise use "% or %" wording. gcc/testsuite/ * c-c++-common/gomp/declare-target-2.c: Add further tests for mixing of link and to/enter clauses on separate directives. (cherry picked from commit 931249276acb4bdab778fe2bf4e81a1a31a78e6c) Diff: --- gcc/c/ChangeLog.omp | 10 ++++++++++ gcc/c/c-parser.cc | 11 ++++++++--- gcc/cp/ChangeLog.omp | 10 ++++++++++ gcc/cp/parser.cc | 11 ++++++++--- gcc/testsuite/ChangeLog.omp | 8 ++++++++ gcc/testsuite/c-c++-common/gomp/declare-target-2.c | 17 ++++++++++++++++- 6 files changed, 60 insertions(+), 7 deletions(-) diff --git a/gcc/c/ChangeLog.omp b/gcc/c/ChangeLog.omp index 9deef6d31b5..667e2b4bcac 100644 --- a/gcc/c/ChangeLog.omp +++ b/gcc/c/ChangeLog.omp @@ -1,3 +1,13 @@ +2022-07-05 Tobias Burnus + + Backport from mainline: + 2022-05-28 Jakub Jelinek + + * c-parser.cc (c_parser_omp_declare_target): If OMP_CLAUSE_LINK was + seen first, use "%" or "%" depending on + OMP_CLAUSE_ENTER_TO of the current clause, otherwise use + "% or %" wording. + 2022-07-05 Tobias Burnus Backport from mainline: diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 44f222800b7..b01ebdb3cda 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -22359,9 +22359,14 @@ c_parser_omp_declare_target (c_parser *parser) id = get_identifier ("omp declare target"); if (at2) { - error_at (OMP_CLAUSE_LOCATION (c), - "%qD specified both in declare target % and %" - " clauses", t); + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER) + error_at (OMP_CLAUSE_LOCATION (c), + "%qD specified both in declare target % and %qs" + " clauses", t, OMP_CLAUSE_ENTER_TO (c) ? "to" : "enter"); + else + error_at (OMP_CLAUSE_LOCATION (c), + "%qD specified both in declare target % and " + "% or % clauses", t); continue; } if (!at1) diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp index a2122a223f5..453d3e1ffb9 100644 --- a/gcc/cp/ChangeLog.omp +++ b/gcc/cp/ChangeLog.omp @@ -1,3 +1,13 @@ +2022-07-05 Tobias Burnus + + Backport from mainline: + 2022-05-28 Jakub Jelinek + + * parser.cc (handle_omp_declare_target_clause): If OMP_CLAUSE_LINK was + seen first, use "%" or "%" depending on + OMP_CLAUSE_ENTER_TO of the current clause, otherwise use + "% or %" wording. + 2022-07-05 Tobias Burnus Backport from mainline: diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc index dc3bea50eaf..7389cbe9fdf 100644 --- a/gcc/cp/parser.cc +++ b/gcc/cp/parser.cc @@ -46151,9 +46151,14 @@ handle_omp_declare_target_clause (tree c, tree t, int device_type) id = get_identifier ("omp declare target"); if (at2) { - error_at (OMP_CLAUSE_LOCATION (c), - "%qD specified both in declare target % and %" - " clauses", t); + if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER) + error_at (OMP_CLAUSE_LOCATION (c), + "%qD specified both in declare target % and %qs" + " clauses", t, OMP_CLAUSE_ENTER_TO (c) ? "to" : "enter"); + else + error_at (OMP_CLAUSE_LOCATION (c), + "%qD specified both in declare target % and " + "% or % clauses", t); return false; } if (!at1) diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp index f3ce282c15d..34eb1e780f3 100644 --- a/gcc/testsuite/ChangeLog.omp +++ b/gcc/testsuite/ChangeLog.omp @@ -1,3 +1,11 @@ +2022-07-05 Tobias Burnus + + Backport from mainline: + 2022-05-28 Jakub Jelinek + + * c-c++-common/gomp/declare-target-2.c: Add further tests for mixing of + link and to/enter clauses on separate directives. + 2022-07-05 Tobias Burnus Backport from mainline: diff --git a/gcc/testsuite/c-c++-common/gomp/declare-target-2.c b/gcc/testsuite/c-c++-common/gomp/declare-target-2.c index 44fb14daf87..97602dc7992 100644 --- a/gcc/testsuite/c-c++-common/gomp/declare-target-2.c +++ b/gcc/testsuite/c-c++-common/gomp/declare-target-2.c @@ -10,7 +10,22 @@ int b; #pragma omp declare target enter (b) link (b) /* { dg-error "appears more than once on the same .declare target. directive" } */ int c; #pragma omp declare target (c) -#pragma omp declare target link (c) /* { dg-error "specified both in declare target" } */ +#pragma omp declare target link (c) /* { dg-error "specified both in declare target 'link' and 'to' or 'enter' clauses" } */ +int c2; +#pragma omp declare target to (c2) +#pragma omp declare target link (c2) /* { dg-error "specified both in declare target 'link' and 'to' or 'enter' clauses" } */ +int c3; +#pragma omp declare target enter (c3) +#pragma omp declare target link (c3) /* { dg-error "specified both in declare target 'link' and 'to' or 'enter' clauses" } */ +int c4; +#pragma omp declare target link (c4) +#pragma omp declare target (c4) /* { dg-error "specified both in declare target 'link' and 'enter' clauses" } */ +int c5; +#pragma omp declare target link (c5) +#pragma omp declare target to (c5) /* { dg-error "specified both in declare target 'link' and 'to' clauses" } */ +int c6; +#pragma omp declare target link (c6) +#pragma omp declare target enter (c6) /* { dg-error "specified both in declare target 'link' and 'enter' clauses" } */ int foo (void); #pragma omp declare target link (foo) /* { dg-error "is not a variable in clause" } */ struct S;