public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1990] openmp: Reject #pragma omp atomic update, [PR101297]
@ 2021-07-02 19:58 Jakub Jelinek
0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2021-07-02 19:58 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:2ca89394280da4afad6074ec3cb7136b6142af7b
commit r12-1990-g2ca89394280da4afad6074ec3cb7136b6142af7b
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Jul 2 21:57:24 2021 +0200
openmp: Reject #pragma omp atomic update, [PR101297]
I've noticed that we allow a trailing comma on OpenMP atomic construct
if there is at least one clause. Commas should be only allowed to
separate the clauses (or in OpenMP 5.1 to separate directive name
from the clauses).
2021-07-02 Jakub Jelinek <jakub@redhat.com>
PR c/101297
* c-parser.c (c_parser_omp_atomic): Consume comma only if it
appears before a CPP_NAME.
* parser.c (cp_parser_omp_atomic): Consume comma only if it
appears before a CPP_NAME.
* c-c++-common/gomp/atomic-24.c: New test.
Diff:
---
gcc/c/c-parser.c | 4 +++-
gcc/cp/parser.c | 4 +++-
gcc/testsuite/c-c++-common/gomp/atomic-24.c | 12 ++++++++++++
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 3922b569c3a..9a56e0c04c6 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -17533,7 +17533,9 @@ c_parser_omp_atomic (location_t loc, c_parser *parser, bool openacc)
while (c_parser_next_token_is_not (parser, CPP_PRAGMA_EOL))
{
- if (!first && c_parser_next_token_is (parser, CPP_COMMA))
+ if (!first
+ && c_parser_next_token_is (parser, CPP_COMMA)
+ && c_parser_peek_2nd_token (parser)->type == CPP_NAME)
c_parser_consume_token (parser);
first = false;
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 02daa7a6f6a..3550cd06dc1 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -39171,7 +39171,9 @@ cp_parser_omp_atomic (cp_parser *parser, cp_token *pragma_tok, bool openacc)
while (cp_lexer_next_token_is_not (parser->lexer, CPP_PRAGMA_EOL))
{
- if (!first && cp_lexer_next_token_is (parser->lexer, CPP_COMMA))
+ if (!first
+ && cp_lexer_next_token_is (parser->lexer, CPP_COMMA)
+ && cp_lexer_nth_token_is (parser->lexer, 2, CPP_NAME))
cp_lexer_consume_token (parser->lexer);
first = false;
diff --git a/gcc/testsuite/c-c++-common/gomp/atomic-24.c b/gcc/testsuite/c-c++-common/gomp/atomic-24.c
new file mode 100644
index 00000000000..f70c8051023
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/atomic-24.c
@@ -0,0 +1,12 @@
+/* PR c/101297 */
+
+int i;
+
+void
+foo (void)
+{
+ #pragma omp atomic update, /* { dg-error "expected end of line before ',' token" } */
+ i++;
+ #pragma omp atomic update,, /* { dg-error "expected end of line before ',' token" } */
+ i++;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-02 19:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-02 19:58 [gcc r12-1990] openmp: Reject #pragma omp atomic update, [PR101297] Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).