From 931249276acb4bdab778fe2bf4e81a1a31a78e6c Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Sat, 28 May 2022 08:26:57 +0200 Subject: openmp: Adjust diagnostics about same variable in link and to/enter clauses MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- gcc/c/c-parser.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index 678d914..7cc4d93c 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -22067,9 +22067,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) -- cgit v1.1