]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: Diagnose omp::directive/sequence on using-directive
authorJakub Jelinek <jakub@redhat.com>
Thu, 12 Aug 2021 09:00:51 +0000 (11:00 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Thu, 12 Aug 2021 09:00:51 +0000 (11:00 +0200)
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)

gcc/cp/ChangeLog.omp
gcc/cp/name-lookup.c
gcc/testsuite/ChangeLog.omp
gcc/testsuite/g++.dg/gomp/attrs-11.C

index dbc0245c4d3f8c277ad598167a15a64cc9a94ab2..8c1d85ba82a0644a22ba551528402812dace20a2 100644 (file)
@@ -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:
index d4387c09ef8915d9797c377f689f9e713e2a783a..0c95e5c00adf227b5dd3ba2049586825e14f3b43 100644 (file)
@@ -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);
       }
index fa94fc47017a791189cee759141c40a8da525b6b..bb0605f1918c71984d99f696df7776c293df76a4 100644 (file)
@@ -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:
index a8e27b74df5014908245d1428b985df39c4898bf..009bcb2d87f69829da73a795b7d90e6d9614dacf 100644 (file)
@@ -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" }