]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
openmp: For C++ ensure nothing directive has no operands
authorJakub Jelinek <jakub@redhat.com>
Thu, 19 Aug 2021 10:03:03 +0000 (12:03 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Thu, 19 Aug 2021 10:03:22 +0000 (12:03 +0200)
When working on error directive, I've noticed that while C FE diagnosed
clauses on nothing directive which doesn't allow any, the C++ FE silently
accepted it.

2021-08-19  Jakub Jelinek  <jakub@redhat.com>

* parser.c (cp_parser_omp_nothing): Use cp_parser_require_pragma_eol
instead of cp_parser_skip_to_pragma_eol.

* c-c++-common/gomp/nothing-2.c: New test.

(cherry picked from commit 4e6a5fa403782590088b2796261b023963f912af)

gcc/cp/ChangeLog.omp
gcc/cp/parser.c
gcc/testsuite/ChangeLog.omp
gcc/testsuite/c-c++-common/gomp/nothing-2.c [new file with mode: 0644]

index 056143047696faa3b81e1cff6cead39b50c1fd28..c58f82443dfe23443cf8462eb785d992edf99bd4 100644 (file)
@@ -1,3 +1,11 @@
+2021-08-19  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backported from master:
+       2021-08-19  Jakub Jelinek  <jakub@redhat.com>
+
+       * parser.c (cp_parser_omp_nothing): Use cp_parser_require_pragma_eol
+       instead of cp_parser_skip_to_pragma_eol.
+
 2021-08-18  Tobias Burnus  <tobias@codesourcery.com>
 
        Backported from master:
index 5b9d42f6ccf06360f83202f23b1acad8cb5406ef..c3274a265bdf7d38c0941dcc804ff2aaa2b2cda9 100644 (file)
@@ -45359,7 +45359,7 @@ cp_parser_omp_requires (cp_parser *parser, cp_token *pragma_tok)
 static void
 cp_parser_omp_nothing (cp_parser *parser, cp_token *pragma_tok)
 {
-  cp_parser_skip_to_pragma_eol (parser, pragma_tok);
+  cp_parser_require_pragma_eol (parser, pragma_tok);
 }
 
 
index 888162ba07781f0101e8e179000a1c84d59730fa..d64dae15792672761d477721dfd1df6845983d30 100644 (file)
@@ -1,3 +1,10 @@
+2021-08-19  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backported from master:
+       2021-08-19  Jakub Jelinek  <jakub@redhat.com>
+
+       * c-c++-common/gomp/nothing-2.c: New test.
+
 2021-08-19  Tobias Burnus  <tobias@codesourcery.com>
 
        Backported from master:
diff --git a/gcc/testsuite/c-c++-common/gomp/nothing-2.c b/gcc/testsuite/c-c++-common/gomp/nothing-2.c
new file mode 100644 (file)
index 0000000..a152035
--- /dev/null
@@ -0,0 +1,2 @@
+#pragma omp nothing ,          /* { dg-error "expected end of line before" } */
+#pragma omp nothing asdf       /* { dg-error "expected end of line before" } */