]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
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 19:01:46 +0000 (21:01 +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 1bfcefb875bdf767d5c00d7fbc112ce9b9056807..3439f6d4e6518b97b03f05631b7adacc21bf9e1d 100644 (file)
@@ -1,5 +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.
+
        Backported from mainline
        2020-03-23  Jakub Jelinek  <jakub@redhat.com>
 
index 042ae876d1c55d4e08f90a4863e4715ea262a2f1..d0139ab4b8659a5b7a09eb4d5ac407b39415387f 100644 (file)
@@ -17631,9 +17631,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 (!flag_openmp)  /* flag_openmp_simd  */
index ae33956b867f7036e365480e9f05d9e609700bb5..cb49aeccafa7feeba0fa58c4b724b745eb2141f9 100644 (file)
@@ -1,5 +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.
+
        Backported from mainline
        2020-04-04  Jakub Jelinek  <jakub@redhat.com>
 
index 00e950d2e9370abbe7057a10bdb3f1eb1cc29fde..db0276eb04fbe2766b7abbf6a1993a650ad48ac0 100644 (file)
@@ -37820,9 +37820,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 (!flag_openmp)  /* flag_openmp_simd  */
index 660def73d7f880a3300dbfb67950c02919f50a33..7aed8e289c167fb01b8e52e17c40a83cfdad711e 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/94488
        * gcc.c-torture/compile/pr94488.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> ();
+}