public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-11] openmp: Diagnose omp::directive/sequence on using-directive
@ 2021-08-12 10:00 Tobias Burnus
  0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2021-08-12 10:00 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:6843be6997fcb42c7e3c0a8d60c90883aff0fbf9

commit 6843be6997fcb42c7e3c0a8d60c90883aff0fbf9
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Aug 12 11:00:51 2021 +0200

    openmp: Diagnose omp::directive/sequence on using-directive
    
    With the using-directive parsing changes, we now emit only a warning
    for [[omp::directive (...)]] on using-directive.  While that is right
    without -fopenmp/-fopenmp-simd, when OpenMP is enabled, that should
    be an error as OpenMP (is going to) disallow such attributes there
    as they do not appertain to a statement.
    
    2021-08-12  Jakub Jelinek  <jakub@redhat.com>
    
            * name-lookup.c (finish_using_directive): Diagnose omp::directive
            or omp::sequence attributes on using-directive.
    
            * g++.dg/gomp/attrs-11.C: Adjust expected diagnostics.
    
    (cherry picked from commit c84f79e9e3f63e9ae447fd15dbd0a768cab3f643)

Diff:
---
 gcc/cp/ChangeLog.omp                 |  8 ++++++++
 gcc/cp/name-lookup.c                 | 11 +++++++++++
 gcc/testsuite/ChangeLog.omp          |  7 +++++++
 gcc/testsuite/g++.dg/gomp/attrs-11.C |  2 +-
 4 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/ChangeLog.omp b/gcc/cp/ChangeLog.omp
index dbc0245c4d3..8c1d85ba82a 100644
--- a/gcc/cp/ChangeLog.omp
+++ b/gcc/cp/ChangeLog.omp
@@ -1,3 +1,11 @@
+2021-08-12  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2021-08-12  Jakub Jelinek  <jakub@redhat.com>
+
+	* name-lookup.c (finish_using_directive): Diagnose omp::directive
+	or omp::sequence attributes on using-directive.
+
 2021-08-10  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index d4387c09ef8..0c95e5c00ad 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -8582,6 +8582,7 @@ finish_using_directive (tree target, tree attribs)
   add_using_namespace (current_binding_level->using_directives,
 		       ORIGINAL_NAMESPACE (target));
 
+  bool diagnosed = false;
   if (attribs != error_mark_node)
     for (tree a = attribs; a; a = TREE_CHAIN (a))
       {
@@ -8594,6 +8595,16 @@ finish_using_directive (tree target, tree attribs)
 	      inform (DECL_SOURCE_LOCATION (target),
 		      "you can use an inline namespace instead");
 	  }
+	else if ((flag_openmp || flag_openmp_simd)
+		 && get_attribute_namespace (a) == omp_identifier
+		 && (is_attribute_p ("directive", name)
+		     || is_attribute_p ("sequence", name)))
+	  {
+	    if (!diagnosed)
+	      error ("%<omp::%E%> not allowed to be specified in this "
+		     "context", name);
+	    diagnosed = true;
+	  }
 	else
 	  warning (OPT_Wattributes, "%qD attribute directive ignored", name);
       }
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index fa94fc47017..bb0605f1918 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,10 @@
+2021-08-12  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2021-08-12  Jakub Jelinek  <jakub@redhat.com>
+
+	* g++.dg/gomp/attrs-11.C: Adjust expected diagnostics.
+
 2021-08-10  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/testsuite/g++.dg/gomp/attrs-11.C b/gcc/testsuite/g++.dg/gomp/attrs-11.C
index a8e27b74df5..009bcb2d87f 100644
--- a/gcc/testsuite/g++.dg/gomp/attrs-11.C
+++ b/gcc/testsuite/g++.dg/gomp/attrs-11.C
@@ -11,7 +11,7 @@ foo ()
   [[omp::directive (parallel)]] __extension__ asm ("");		// { dg-error "expected" }
   __extension__ [[omp::directive (parallel)]] asm ("");		// { dg-error "expected" }
   [[omp::directive (parallel)]] namespace M = ::N;		// { dg-error "expected" }
-  [[omp::directive (parallel)]] using namespace N;		// { dg-bogus "expected" "" { xfail *-*-* } }
+  [[omp::directive (parallel)]] using namespace N;		// { dg-error "not allowed to be specified in this context" }
   [[omp::directive (parallel)]] using O::T;			// { dg-error "expected" }
   [[omp::directive (parallel)]] __label__ foo;			// { dg-error "expected" }
   [[omp::directive (parallel)]] static_assert (true, "");	// { dg-error "expected" }


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

only message in thread, other threads:[~2021-08-12 10:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-12 10:00 [gcc/devel/omp/gcc-11] openmp: Diagnose omp::directive/sequence on using-directive Tobias Burnus

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).