This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix error recovery on invalid OpenMP clauses (PR c/67501)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]