public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-807] openmp: Adjust diagnostics about same variable in link and to/enter clauses
@ 2022-05-28  6:30 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2022-05-28  6:30 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:931249276acb4bdab778fe2bf4e81a1a31a78e6c

commit r13-807-g931249276acb4bdab778fe2bf4e81a1a31a78e6c
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat May 28 08:26:57 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  <jakub@redhat.com>
    
    gcc/c/
            * c-parser.cc (c_parser_omp_declare_target): If OMP_CLAUSE_LINK was
            seen first, use "%<to%>" or "%<enter%>" depending on
            OMP_CLAUSE_ENTER_TO of the current clause, otherwise use
            "%<to%> or %<enter%>" wording.
    gcc/cp/
            * parser.cc (handle_omp_declare_target_clause): If OMP_CLAUSE_LINK was
            seen first, use "%<to%>" or "%<enter%>" depending on
            OMP_CLAUSE_ENTER_TO of the current clause, otherwise use
            "%<to%> or %<enter%>" 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.

Diff:
---
 gcc/c/c-parser.cc                                  | 11 ++++++++---
 gcc/cp/parser.cc                                   | 11 ++++++++---
 gcc/testsuite/c-c++-common/gomp/declare-target-2.c | 17 ++++++++++++++++-
 3 files changed, 32 insertions(+), 7 deletions(-)

diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 678d91415a9..7cc4d93cf87 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 %<link%> and %<to%>"
-		    " clauses", t);
+	  if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
+	    error_at (OMP_CLAUSE_LOCATION (c),
+		      "%qD specified both in declare target %<link%> and %qs"
+		      " clauses", t, OMP_CLAUSE_ENTER_TO (c) ? "to" : "enter");
+	  else
+	    error_at (OMP_CLAUSE_LOCATION (c),
+		      "%qD specified both in declare target %<link%> and "
+		      "%<to%> or %<enter%> clauses", t);
 	  continue;
 	}
       if (!at1)
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 9a9f859974a..b3a6c9ab6e3 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -45992,9 +45992,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 %<link%> and %<to%>"
-		" clauses", t);
+      if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_ENTER)
+	error_at (OMP_CLAUSE_LOCATION (c),
+		  "%qD specified both in declare target %<link%> and %qs"
+		  " clauses", t, OMP_CLAUSE_ENTER_TO (c) ? "to" : "enter");
+      else
+	error_at (OMP_CLAUSE_LOCATION (c),
+		  "%qD specified both in declare target %<link%> and "
+		  "%<to%> or %<enter%> clauses", t);
       return false;
     }
   if (!at1)
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;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-28  6:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-28  6:30 [gcc r13-807] openmp: Adjust diagnostics about same variable in link and to/enter clauses Jakub Jelinek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).