public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-11] openmp: Diagnose some superfluous commas in OpenMP parsing
@ 2021-08-20 13:31 Tobias Burnus
0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2021-08-20 13:31 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:6c8be163b35e3700910ce1c625dfc2e377bb49e7
commit 6c8be163b35e3700910ce1c625dfc2e377bb49e7
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Aug 20 14:13:36 2021 +0200
openmp: Diagnose some superfluous commas in OpenMP parsing
While working on error directive, I've noticed a few spots in OpenMP
parsing where we consume and don't diagnose superfluous commas at the end
(either of depend sink arguments or at the end of requires pragma).
2021-08-20 Jakub Jelinek <jakub@redhat.com>
gcc/c/
* c-parser.c (c_parser_omp_clause_depend_sink): Reject spurious
comma at the end of list.
(c_parser_omp_requires): Likewise.
gcc/cp/
* parser.c (cp_parser_omp_clause_depend_sink): Reject spurious
comma at the end of list. Don't parse closing paren here...
(cp_parser_omp_clause_depend): ... but here instead.
gcc/testsuite/
* c-c++-common/gomp/sink-5.c: New test.
* c-c++-common/gomp/requires-3.c: Add test for spurious comma
at the end of pragma line.
(cherry picked from commit f9400e4e4705845f2b0cdc4eab30c214e0e4cbe0)
Diff:
---
gcc/c/ChangeLog.omp | 9 +++++++++
gcc/c/c-parser.c | 8 ++++++--
gcc/cp/ChangeLog.omp | 9 +++++++++
gcc/cp/parser.c | 13 ++++++++++---
gcc/testsuite/ChangeLog.omp | 25 +++++++++++++++++--------
gcc/testsuite/c-c++-common/gomp/requires-3.c | 1 +
gcc/testsuite/c-c++-common/gomp/sink-5.c | 16 ++++++++++++++++
7 files changed, 68 insertions(+), 13 deletions(-)
diff --git a/gcc/c/ChangeLog.omp b/gcc/c/ChangeLog.omp
index f9aab5b5434..b28671f2b2f 100644
--- a/gcc/c/ChangeLog.omp
+++ b/gcc/c/ChangeLog.omp
@@ -1,3 +1,12 @@
+2021-08-20 Tobias Burnus <tobias@codesourcery.com>
+
+ Backported from master:
+ 2021-08-20 Jakub Jelinek <jakub@redhat.com>
+
+ * c-parser.c (c_parser_omp_clause_depend_sink): Reject spurious
+ comma at the end of list.
+ (c_parser_omp_requires): Likewise.
+
2021-08-19 Tobias Burnus <tobias@codesourcery.com>
Backported from master:
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 94539225327..389a749dce9 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -15498,7 +15498,9 @@ c_parser_omp_clause_depend_sink (c_parser *parser, location_t clause_loc,
OMP_CLAUSE_DEPEND_SINK_NEGATIVE (vec) = 1;
}
- if (c_parser_next_token_is_not (parser, CPP_COMMA))
+ if (c_parser_next_token_is_not (parser, CPP_COMMA)
+ || c_parser_peek_2nd_token (parser)->type != CPP_NAME
+ || c_parser_peek_2nd_token (parser)->id_kind != C_ID_ID)
break;
c_parser_consume_token (parser);
@@ -21684,7 +21686,9 @@ c_parser_omp_requires (c_parser *parser)
location_t loc = c_parser_peek_token (parser)->location;
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/ChangeLog.omp b/gcc/cp/ChangeLog.omp
index 2dc4c7411a7..f3ab79c467c 100644
--- a/gcc/cp/ChangeLog.omp
+++ b/gcc/cp/ChangeLog.omp
@@ -1,3 +1,12 @@
+2021-08-20 Tobias Burnus <tobias@codesourcery.com>
+
+ Backported from master:
+ 2021-08-20 Jakub Jelinek <jakub@redhat.com>
+
+ * parser.c (cp_parser_omp_clause_depend_sink): Reject spurious
+ comma at the end of list. Don't parse closing paren here...
+ (cp_parser_omp_clause_depend): ... but here instead.
+
2021-08-19 Tobias Burnus <tobias@codesourcery.com>
Backported from master:
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index cfe58f672de..11d2f438021 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -38295,13 +38295,14 @@ cp_parser_omp_clause_depend_sink (cp_parser *parser, location_t clause_loc,
OMP_CLAUSE_DEPEND_SINK_NEGATIVE (vec) = 1;
}
- if (cp_lexer_next_token_is_not (parser->lexer, CPP_COMMA))
+ if (cp_lexer_next_token_is_not (parser->lexer, CPP_COMMA)
+ || !cp_lexer_nth_token_is (parser->lexer, 2, CPP_NAME))
break;
cp_lexer_consume_token (parser->lexer);
}
- if (cp_parser_require (parser, CPP_CLOSE_PAREN, RT_CLOSE_PAREN) && vec)
+ if (vec)
{
tree u = build_omp_clause (clause_loc, OMP_CLAUSE_DEPEND);
OMP_CLAUSE_DEPEND_KIND (u) = OMP_CLAUSE_DEPEND_SINK;
@@ -38621,7 +38622,13 @@ cp_parser_omp_clause_depend (cp_parser *parser, tree list, location_t loc)
goto resync_fail;
if (kind == OMP_CLAUSE_DEPEND_SINK)
- nlist = cp_parser_omp_clause_depend_sink (parser, loc, list);
+ {
+ nlist = cp_parser_omp_clause_depend_sink (parser, loc, list);
+ if (!parens.require_close (parser))
+ cp_parser_skip_to_closing_parenthesis (parser, /*recovering=*/true,
+ /*or_comma=*/false,
+ /*consume_paren=*/true);
+ }
else
{
nlist = cp_parser_omp_var_list_no_open (parser, OMP_CLAUSE_DEPEND,
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 4385c18ca7b..7b27cb3cfb0 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,12 @@
+2021-08-20 Tobias Burnus <tobias@codesourcery.com>
+
+ Backported from master:
+ 2021-08-20 Jakub Jelinek <jakub@redhat.com>
+
+ * c-c++-common/gomp/sink-5.c: New test.
+ * c-c++-common/gomp/requires-3.c: Add test for spurious comma
+ at the end of pragma line.
+
2021-08-11 Sandra Loosemore <sandra@codesourcery.com>
Backported from master:
@@ -48,7 +57,7 @@
2021-07-24 Sandra Loosemore <sandra@codesourcery.com>
- PR libfortran/101317
+ PR libfortran/101317
* gfortran.dg/ISO_Fortran_binding_17.f90: Fix typo in error
message patterns.
@@ -1024,7 +1033,7 @@
* gfortran.dg/goacc/loop-2-kernels.f95: Add XFAILs.
2020-07-24 Kwok Cheung Yeung <kcy@codesourcery.com>
-
+
* gcc.dg/goacc/loop-processing-1.c: Remove erroneous line-break.
Specify correct tree pass for output. Fix expected constant values.
@@ -1369,12 +1378,12 @@
Nathan Sidwell <nathan@acm.org>
Julian Brown <julian@codesourcery.com>
- * c-c++-common/goacc/orphan-reductions-1.c: New test.
- * c-c++-common/goacc/reduction-7.c: New test.
- * c-c++-common/goacc/routine-4.c: Update.
- * g++.dg/goacc/reductions-1.C: New test.
- * gcc.dg/goacc/loop-processing-1.c: Update.
- * gfortran.dg/goacc/orphan-reductions-1.f90: New test.
+ * c-c++-common/goacc/orphan-reductions-1.c: New test.
+ * c-c++-common/goacc/reduction-7.c: New test.
+ * c-c++-common/goacc/routine-4.c: Update.
+ * g++.dg/goacc/reductions-1.C: New test.
+ * gcc.dg/goacc/loop-processing-1.c: Update.
+ * gfortran.dg/goacc/orphan-reductions-1.f90: New test.
2018-06-29 Cesar Philippidis <cesar@codesourcery.com>
James Norris <jnorris@codesourcery.com>
diff --git a/gcc/testsuite/c-c++-common/gomp/requires-3.c b/gcc/testsuite/c-c++-common/gomp/requires-3.c
index 0e55b666ebf..bd2479ba8ff 100644
--- a/gcc/testsuite/c-c++-common/gomp/requires-3.c
+++ b/gcc/testsuite/c-c++-common/gomp/requires-3.c
@@ -3,3 +3,4 @@
#pragma omp requires atomic_default_mem_order(foobar) /* { dg-error "expected 'seq_cst', 'relaxed' or 'acq_rel'" } */
#pragma omp requires atomic_default_mem_order ( /* { dg-error "expected 'seq_cst', 'relaxed' or 'acq_rel'" } */
/* { dg-error "expected '\\\)' before end of line" "" { target *-*-* } .-1 } */
+#pragma omp requires atomic_default_mem_order(seq_cst), /* { dg-error "expected end of line before ',' token" } */
diff --git a/gcc/testsuite/c-c++-common/gomp/sink-5.c b/gcc/testsuite/c-c++-common/gomp/sink-5.c
new file mode 100644
index 00000000000..4fbaa8a03cb
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/sink-5.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+void bar (int);
+
+void
+foo ()
+{
+ int i;
+#pragma omp parallel for ordered(1)
+ for (i = 0; i < 100; ++i)
+ {
+#pragma omp ordered depend(sink:i-1,) /* { dg-error "expected '\\\)' before ',' token" } */
+ bar (i);
+#pragma omp ordered depend(source)
+ }
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-08-20 13:31 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20 13:31 [gcc/devel/omp/gcc-11] openmp: Diagnose some superfluous commas in OpenMP parsing Tobias Burnus
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).