Hi!

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.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk.

2021-08-19  Jakub Jelinek  <ja...@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.

--- gcc/cp/parser.c.jj  2021-08-18 11:10:34.926868957 +0200
+++ gcc/cp/parser.c     2021-08-18 18:53:23.894424288 +0200
@@ -45570,7 +45570,7 @@ cp_parser_omp_requires (cp_parser *parse
 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);
 }
 
 
--- gcc/testsuite/c-c++-common/gomp/nothing-2.c.jj      2021-08-18 
18:35:22.068409297 +0200
+++ gcc/testsuite/c-c++-common/gomp/nothing-2.c 2021-08-18 18:35:54.499960209 
+0200
@@ -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" } */

        Jakub

Reply via email to