From 4df50a059fbd4d4a1cb067bd43caccdfca0327a8 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Tue, 7 Apr 2020 14:30:53 +0200 Subject: [PATCH] openmp: Fix parallel master error recovery [PR94512] 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 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 | 6 ++++++ gcc/c/c-parser.c | 2 +- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/parser.c | 2 +- gcc/testsuite/ChangeLog | 3 +++ gcc/testsuite/g++.dg/gomp/pr94512.C | 18 ++++++++++++++++++ 6 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/gomp/pr94512.C diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index a3350c2b9d1..d30d2b02b2e 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,9 @@ +2020-04-07 Jakub Jelinek + + 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 PR gcov-profile/94029 diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index aeeac8c5f21..17a28e97ca0 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -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) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 02fd9cff79d..4452796f2fa 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-04-07 Jakub Jelinek + + PR c++/94512 + * parser.c (cp_parser_omp_parallel): Set OMP_PARALLEL_COMBINED + if cp_parser_omp_master succeeded. + 2020-04-06 Jason Merrill PR c++/94462 diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 7e5921e039f..fbcdc9bb5fc 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -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) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index d9209f920ae..da2664b7d7f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2020-04-07 Jakub Jelinek + 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 index 00000000000..8ba0e65795f --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/pr94512.C @@ -0,0 +1,18 @@ +// PR c++/94512 + +void +foo (); + +template +void +bar () +{ +#pragma omp parallel master taskloop + foo (); // { dg-error "for statement expected before" } +} + +void +baz () +{ + bar<0> (); +} -- 2.30.2