[committed] openmp: Fix ICE on #pragma omp parallel master in template [PR94477]

Message ID 20200403223821.GB2163@tucnak
State New
Headers show
Series
  • [committed] openmp: Fix ICE on #pragma omp parallel master in template [PR94477]
Related show

Commit Message

Xionghu Luo via Gcc-patches April 3, 2020, 10:38 p.m.
Hi!

The following testcase ICEs, because for parallel combined with some
other construct we initialize the omp_parallel_combined_clauses pointer
and expect the construct combined with it to clear it after it no longer
needs it, but OMP_MASTER didn't do that.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk,
queued for backporting.

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

	PR c++/94477
	* pt.c (tsubst_expr) <case OMP_MASTER>: Clear
	omp_parallel_combined_clauses.

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


	Jakub

Patch

--- gcc/cp/pt.c.jj	2020-04-03 20:28:50.989754551 +0200
+++ gcc/cp/pt.c	2020-04-03 21:54:29.754337004 +0200
@@ -18467,8 +18467,10 @@  tsubst_expr (tree t, tree args, tsubst_f
       add_stmt (t);
       break;
 
-    case OMP_SECTION:
     case OMP_MASTER:
+      omp_parallel_combined_clauses = NULL;
+      /* FALLTHRU */
+    case OMP_SECTION:
       stmt = push_stmt_list ();
       RECUR (OMP_BODY (t));
       stmt = pop_stmt_list (stmt);
--- gcc/testsuite/g++.dg/gomp/pr94477.C.jj	2020-04-03 21:55:10.575740787 +0200
+++ gcc/testsuite/g++.dg/gomp/pr94477.C	2020-04-03 21:54:52.388006422 +0200
@@ -0,0 +1,18 @@ 
+// PR c++/94477
+// { dg-do compile }
+
+void foo ();
+
+template <int>
+void
+bar ()
+{
+  #pragma omp parallel master
+  foo ();
+}
+
+void
+baz ()
+{
+  bar<0> ();
+}