diff options
author | Jakub Jelinek <jakub@redhat.com> | 2021-07-02 21:57:24 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2021-07-02 21:57:24 +0200 |
commit | 2ca89394280da4afad6074ec3cb7136b6142af7b (patch) | |
tree | 040ffd0b44805914dd7c6bae2d9b5d71f3772ef3 /gcc/c/c-parser.c | |
parent | e3528ce197f8886869f95e8a8f901861a319851c (diff) | |
download | gcc-2ca89394280da4afad6074ec3cb7136b6142af7b.zip gcc-2ca89394280da4afad6074ec3cb7136b6142af7b.tar.gz gcc-2ca89394280da4afad6074ec3cb7136b6142af7b.tar.bz2 |
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.
Diffstat (limited to 'gcc/c/c-parser.c')
-rw-r--r-- | gcc/c/c-parser.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 3922b56..9a56e0c 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; |