aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/name-lookup.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-08-12 09:10:46 +0200
committerJakub Jelinek <jakub@redhat.com>2021-08-12 09:34:16 +0200
commitc84f79e9e3f63e9ae447fd15dbd0a768cab3f643 (patch)
tree5129dddf08f954314d6153bde16e0bc39a261b4f /gcc/cp/name-lookup.c
parent3890c28ac5bd03ba334a20fbf9518a37dcdbfe5d (diff)
downloadgcc-c84f79e9e3f63e9ae447fd15dbd0a768cab3f643.zip
gcc-c84f79e9e3f63e9ae447fd15dbd0a768cab3f643.tar.gz
gcc-c84f79e9e3f63e9ae447fd15dbd0a768cab3f643.tar.bz2
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.
Diffstat (limited to 'gcc/cp/name-lookup.c')
-rw-r--r--gcc/cp/name-lookup.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 1be5f3d..8e9c61e 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -8560,6 +8560,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))
{
@@ -8572,6 +8573,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);
}