openmp: Fix parallel master error recovery [PR94512]
authorJakub Jelinek <jakub@redhat.com>
Tue, 7 Apr 2020 12:30:53 +0000 (14:30 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 7 Apr 2020 12:30:53 +0000 (14:30 +0200)
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.

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.

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

index a3350c2b9d18fb20fef294db53d9fde3e36eafcb..d30d2b02b2e2b77b1fa1a2f438c9d47d00ab4953 100644 (file)
@@ -1,3 +1,9 @@
+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.
+
 2020-03-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR gcov-profile/94029
index aeeac8c5f21b16d7f9fd284fbe3e77de829639e7..17a28e97ca0e3d81248fab9e818e5adfd5644e5b 100644 (file)
@@ -18877,9 +18877,9 @@ c_parser_omp_parallel (location_t loc, c_parser *parser,
          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)
index 02fd9cff79ddc87f397a90607ab40d881a360dc1..4452796f2fa7e800ebd02e86801d57f70dde043d 100644 (file)
@@ -1,3 +1,9 @@
+2020-04-07  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c++/94512
+       * parser.c (cp_parser_omp_parallel): Set OMP_PARALLEL_COMBINED
+       if cp_parser_omp_master succeeded.
+
 2020-04-06  Jason Merrill  <jason@redhat.com>
 
        PR c++/94462
index 7e5921e039f18b3cb68ac1b910ae7357c95fa723..fbcdc9bb5fc96cf4f760ab99e480562d1dc22e02 100644 (file)
@@ -39818,9 +39818,9 @@ cp_parser_omp_parallel (cp_parser *parser, cp_token *pragma_tok,
          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)
index d9209f920aed38123d8cfc29d3981d9cd20c3874..da2664b7d7f43ff41b17049c5b26e91eab511c2d 100644 (file)
@@ -1,5 +1,8 @@
 2020-04-07  Jakub Jelinek  <jakub@redhat.com>
 
+       PR c++/94512
+       * g++.dg/gomp/pr94512.C: New test.
+
        PR target/94500
        * gcc.target/i386/avx512bw-pr94500.c: New test.
 
diff --git a/gcc/testsuite/g++.dg/gomp/pr94512.C b/gcc/testsuite/g++.dg/gomp/pr94512.C
new file mode 100644 (file)
index 0000000..8ba0e65
--- /dev/null
@@ -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> ();
+}