This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix error recovery on invalid OpenMP clauses (PR c/67501)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: "Joseph S. Myers" <joseph at codesourcery dot com>, Marek Polacek <polacek at redhat dot com>
- Date: Wed, 9 Sep 2015 09:44:22 +0200
- Subject: [PATCH] Fix error recovery on invalid OpenMP clauses (PR c/67501)
- Authentication-results: sourceware.org; auth=none
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
If some OpenMP clause is parsed including the argument, such that
OMP_CLAUSE tree is created, but there is some error afterwards,
the C FE fails to remove the clause if it is not allowed for the
current construct, which results in ICEs later on (e.g. during
clause splitting). While it would be enough to just remove the
clause in this case (clauses = prev;), for consistency with the
C++ FE I've decided to also emit the diagnostics that the
clause is not valid for the construct.
Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk
and 5 branch.
2015-09-09 Jakub Jelinek <jakub@redhat.com>
PR c/67501
* c-parser.c (c_parser_oacc_all_clauses,
c_parser_omp_all_clauses): Remove invalid clause from
list of clauses even if parser->error is set.
* c-c++-common/gomp/pr67501.c: New test.
--- gcc/c/c-parser.c.jj 2015-09-08 16:54:12.000000000 +0200
+++ gcc/c/c-parser.c 2015-09-08 17:41:32.134418742 +0200
@@ -11752,7 +11752,7 @@ c_parser_oacc_all_clauses (c_parser *par
first = false;
- if (((mask >> c_kind) & 1) == 0 && !parser->error)
+ if (((mask >> c_kind) & 1) == 0)
{
/* Remove the invalid clause(s) from the list to avoid
confusing the rest of the compiler. */
@@ -11981,7 +11981,7 @@ c_parser_omp_all_clauses (c_parser *pars
first = false;
- if (((mask >> c_kind) & 1) == 0 && !parser->error)
+ if (((mask >> c_kind) & 1) == 0)
{
/* Remove the invalid clause(s) from the list to avoid
confusing the rest of the compiler. */
--- gcc/testsuite/c-c++-common/gomp/pr67501.c.jj 2015-09-08 17:42:53.624215866 +0200
+++ gcc/testsuite/c-c++-common/gomp/pr67501.c 2015-09-08 17:42:19.000000000 +0200
@@ -0,0 +1,12 @@
+/* PR c/67501 */
+/* { dg-do compile } */
+/* { dg-options "-fopenmp" } */
+
+void
+foo (void)
+{
+ int i, j;
+ #pragma omp for simd copyprivate(j /* { dg-error "before end of line" } */
+ for (i = 0; i < 16; ++i) /* { dg-error "is not valid for" "" { target *-*-* } 9 } */
+ ;
+}
Jakub