diff mbox series

[committed] openmp: Fix parallel master error recovery [PR94512]

Message ID 20200407123433.GC2212@tucnak
State New
Headers show
Series [committed] openmp: Fix parallel master error recovery [PR94512] | expand

Commit Message

Li, Pan2 via Gcc-patches April 7, 2020, 12:34 p.m. UTC
Hi!

We need to set OMP_PARALLEL_COMBINED only if the parsing of omp_master
succeeded, because otherwise there is no nested master construct in the
parallel.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk, queued for backporting to 9.x.

2020-04-07  Jakub Jelinek  <jakub@redhat.com>

	PR c++/94512
	* c-parser.c (c_parser_omp_parallel): Set OMP_PARALLEL_COMBINED
	if c_parser_omp_master succeeded.

	* parser.c (cp_parser_omp_parallel): Set OMP_PARALLEL_COMBINED
	if cp_parser_omp_master succeeded.

	* g++.dg/gomp/pr94512.C: New test.


	Jakub
diff mbox series

Patch

--- gcc/c/c-parser.c.jj	2020-03-23 19:44:48.271181302 +0100
+++ gcc/c/c-parser.c	2020-04-07 12:28:19.619763021 +0200
@@ -18877,9 +18877,9 @@  c_parser_omp_parallel (location_t loc, c
 	  stmt = c_finish_omp_parallel (loc,
 					cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL],
 					block);
-	  OMP_PARALLEL_COMBINED (stmt) = 1;
 	  if (ret == NULL)
 	    return ret;
+	  OMP_PARALLEL_COMBINED (stmt) = 1;
 	  return stmt;
 	}
       else if (strcmp (p, "loop") == 0)
--- gcc/cp/parser.c.jj	2020-04-04 09:14:29.911001109 +0200
+++ gcc/cp/parser.c	2020-04-07 12:27:21.977628266 +0200
@@ -39818,9 +39818,9 @@  cp_parser_omp_parallel (cp_parser *parse
 	  cp_parser_end_omp_structured_block (parser, save);
 	  stmt = finish_omp_parallel (cclauses[C_OMP_CLAUSE_SPLIT_PARALLEL],
 				      block);
-	  OMP_PARALLEL_COMBINED (stmt) = 1;
 	  if (ret == NULL_TREE)
 	    return ret;
+	  OMP_PARALLEL_COMBINED (stmt) = 1;
 	  return stmt;
 	}
       else if (strcmp (p, "loop") == 0)
--- gcc/testsuite/g++.dg/gomp/pr94512.C.jj	2020-04-07 12:41:31.250883365 +0200
+++ gcc/testsuite/g++.dg/gomp/pr94512.C	2020-04-07 12:40:57.381391551 +0200
@@ -0,0 +1,18 @@ 
+// PR c++/94512
+
+void
+foo ();
+
+template <int>
+void
+bar ()
+{
+#pragma omp parallel master taskloop
+  foo ();	// { dg-error "for statement expected before" }
+}
+
+void
+baz ()
+{
+  bar<0> ();
+}