public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Tobias Burnus <tobias@codesourcery.com>,
	gcc-patches@gcc.gnu.org, fortran <fortran@gcc.gnu.org>
Subject: Re: [Patch] OpenMP/Fortran: Add support for enter clause on declare target (was: [committed] openmp: Add support for enter clause on declare target)
Date: Fri, 27 May 2022 17:44:43 +0200	[thread overview]
Message-ID: <YpDx6+iovCNT6gdP@tucnak> (raw)
In-Reply-To: <YpDsJpcjfSCXmWwd@tucnak>

On Fri, May 27, 2022 at 05:20:08PM +0200, Jakub Jelinek wrote:
> 2) move the
>           else if (n->sym->mark)
>             gfc_error_now ("Variable at %L mentioned multiple times in "
>                            "clauses of the same OMP DECLARE TARGET directive",
>                            &n->where);
>   diagnostics earlier, above
>           else if (n->sym->attr.omp_declare_target
>                    && n->sym->attr.omp_declare_target_link
>                    && list != OMP_LIST_LINK)
>   and adjust testsuite if needed

Note, that matches what the C/C++ FEs do, they also first check for clauses
on the same construct and only afterwards do the link vs. to/enter on
separate directives.

Here is an incremental patch I plan to commit after full testing for the
C/C++ FE wording.

2022-05-27  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.c (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.

--- gcc/c/c-parser.cc.jj	2022-05-26 23:22:30.312850583 +0200
+++ gcc/c/c-parser.cc	2022-05-27 17:28:59.120420300 +0200
@@ -22067,9 +22067,14 @@ c_parser_omp_declare_target (c_parser *p
 	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)
--- gcc/cp/parser.cc.jj	2022-05-26 23:22:30.306850645 +0200
+++ gcc/cp/parser.cc	2022-05-27 17:31:19.086980582 +0200
@@ -45991,9 +45991,14 @@ handle_omp_declare_target_clause (tree c
     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)
--- gcc/testsuite/c-c++-common/gomp/declare-target-2.c.jj	2022-05-27 12:31:36.114087022 +0200
+++ gcc/testsuite/c-c++-common/gomp/declare-target-2.c	2022-05-27 17:38:12.173731493 +0200
@@ -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;

	Jakub


      reply	other threads:[~2022-05-27 15:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <YpCt2rJGuydcFlA4@tucnak>
2022-05-27 14:52 ` Tobias Burnus
2022-05-27 15:20   ` Jakub Jelinek
2022-05-27 15:44     ` Jakub Jelinek [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YpDx6+iovCNT6gdP@tucnak \
    --to=jakub@redhat.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tobias@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).