openmp: Fix ICE on #pragma omp parallel master in template [PR94477]
authorJakub Jelinek <jakub@redhat.com>
Fri, 3 Apr 2020 22:35:41 +0000 (00:35 +0200)
committerJakub Jelinek <jakub@redhat.com>
Fri, 3 Apr 2020 22:35:41 +0000 (00:35 +0200)
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.

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.

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/gomp/pr94477.C [new file with mode: 0644]

index d0b0cb1cac5857a7e373e9cd18e68a88ad54052c..fc3ad899a4a631392e1761205ea9e168eca1948c 100644 (file)
@@ -1,3 +1,9 @@
+2020-04-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/94477
+       * pt.c (tsubst_expr) <case OMP_MASTER>: Clear
+       omp_parallel_combined_clauses.
+
 2020-04-03  Jason Merrill  <jason@redhat.com>
 
        PR c++/91966
index b602f9f82c7e13a6b8b57fe956fc10f953fcf376..6122227c22f483558d39b6c78ecfb9e8db66cbec 100644 (file)
@@ -18467,8 +18467,10 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
       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);
index aad627d84f3df29a375a6f3bd89397b3656debd2..494533f2a559d27c424dcc1f400cd062cbde0e7f 100644 (file)
@@ -1,3 +1,8 @@
+2020-04-04  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/94477
+       * g++.dg/gomp/pr94477.C: New test.
+
 2020-04-03  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR target/94467
diff --git a/gcc/testsuite/g++.dg/gomp/pr94477.C b/gcc/testsuite/g++.dg/gomp/pr94477.C
new file mode 100644 (file)
index 0000000..e7fdc23
--- /dev/null
@@ -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> ();
+}