aboutsummaryrefslogtreecommitdiff
path: root/gcc/c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-04-15 09:59:14 +0200
committerJakub Jelinek <jakub@redhat.com>2020-04-15 09:59:14 +0200
commit2dc9294c3c7c81a6d5e1d4dedf58fea87bbadde6 (patch)
treee5020dd979b8eb5897157a8c3adfd2ec55f78159 /gcc/c
parente71b408aa242ffc76ffd19ebcdbd40279a1d9349 (diff)
downloadgcc-2dc9294c3c7c81a6d5e1d4dedf58fea87bbadde6.zip
gcc-2dc9294c3c7c81a6d5e1d4dedf58fea87bbadde6.tar.gz
gcc-2dc9294c3c7c81a6d5e1d4dedf58fea87bbadde6.tar.bz2
openmp: Reject requires directives not at file or namespace scope [PR94593]
This change started with a bugreport about a typo in one requires testcase (diagnosed with -Wunknown-pragmas only), but following discussion lead to noting that we do not diagnose restriction that requires directives in C/C++ may only appear at file or namespace scope; and several our tests violated that. 2020-04-15 Jakub Jelinek <jakub@redhat.com> PR c/94593 * c-parser.c (c_parser_pragma) <case PRAGMA_OMP_REQUIRES>: Reject requires directive when not at file scope. * parser.c (cp_parser_pragma) <case PRAGMA_OMP_REQUIRES>: Reject requires directive when not at file or namespace scope. * c-c++-common/gomp/requires-1.c: Fix a typo, requries -> requires. Move directives to file scope. (i): Remove. * c-c++-common/gomp/requires-2.c: Move directives to file scope. (i, foo): Remove. * c-c++-common/gomp/requires-4.c: Move directives to file scope. * c-c++-common/gomp/atomic-19.c: Move requires directive to file scope. * c-c++-common/gomp/atomic-20.c: Likewise. * c-c++-common/gomp/atomic-21.c: Likewise. * c-c++-common/gomp/atomic-22.c: Likewise. * gcc.dg/gomp/requires-1.c: New test. * g++.dg/gomp/requires-1.C: New test. * g++.dg/gomp/requires-2.C: New test. * g++.dg/gomp/atomic-18.C: Move requires directive to file scope.
Diffstat (limited to 'gcc/c')
-rw-r--r--gcc/c/ChangeLog6
-rw-r--r--gcc/c/c-parser.c7
2 files changed, 13 insertions, 0 deletions
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 482a01b..a1831d4 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,9 @@
+2020-04-15 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/94593
+ * c-parser.c (c_parser_pragma) <case PRAGMA_OMP_REQUIRES>: Reject
+ requires directive when not at file scope.
+
2020-04-08 Tobias Burnus <tobias@codesourcery.com>
PR middle-end/94120
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index d1c954c..679c14d 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -12402,6 +12402,13 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p)
return false;
case PRAGMA_OMP_REQUIRES:
+ if (context != pragma_external)
+ {
+ error_at (c_parser_peek_token (parser)->location,
+ "%<#pragma omp requires%> may only be used at file scope");
+ c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
+ return false;
+ }
c_parser_omp_requires (parser);
return false;