From f6273d7194651d4d7572cebe55b9e362ac938c99 Mon Sep 17 00:00:00 2001 From: Jinxin Yang Date: Tue, 27 Aug 2019 13:55:18 -0700 Subject: [PATCH] [flang] [OpenMP] structural checks for `PARALLEL SECTIONS` Original-commit: flang-compiler/f18@c18452159d462c98c6a888c272e24ea9d54032f4 --- flang/lib/semantics/check-omp-structure.cc | 9 +++++++- .../test/semantics/omp-clause-validity01.f90 | 22 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/flang/lib/semantics/check-omp-structure.cc b/flang/lib/semantics/check-omp-structure.cc index 8eafd5adacc0..6b2fa2e5f8c1 100644 --- a/flang/lib/semantics/check-omp-structure.cc +++ b/flang/lib/semantics/check-omp-structure.cc @@ -277,7 +277,14 @@ void OmpStructureChecker::Enter(const parser::OpenMPSectionsConstruct &x) { SetContextAllowed(allowed); } break; case parser::OmpSectionsDirective::Directive::ParallelSections: { - // TODO + PushContext(beginDir.source, OmpDirective::PARALLEL_SECTIONS); + OmpClauseSet allowed{OmpClause::DEFAULT, OmpClause::PRIVATE, + OmpClause::FIRSTPRIVATE, OmpClause::LASTPRIVATE, OmpClause::SHARED, + OmpClause::COPYIN, OmpClause::REDUCTION}; + SetContextAllowed(allowed); + OmpClauseSet allowedOnce{ + OmpClause::IF, OmpClause::NUM_THREADS, OmpClause::PROC_BIND}; + SetContextAllowedOnce(allowedOnce); } break; } } diff --git a/flang/test/semantics/omp-clause-validity01.f90 b/flang/test/semantics/omp-clause-validity01.f90 index 309ead63318a..29859992d5ad 100644 --- a/flang/test/semantics/omp-clause-validity01.f90 +++ b/flang/test/semantics/omp-clause-validity01.f90 @@ -210,6 +210,28 @@ !$omp end sections num_threads(4) !$omp end parallel +! 2.11.2 parallel-sections-clause -> parallel-clause | +! sections-clause + + !$omp parallel sections num_threads(4) private(b) lastprivate(d) + a = 0.0 + !$omp section + b = 1 + c = 2 + !$omp section + d = 3 + !$omp end parallel sections + + !ERROR: At most one NUM_THREADS clause can appear on the PARALLEL SECTIONS directive + !$omp parallel sections num_threads(1) num_threads(4) + a = 0.0 + !ERROR: Unmatched END SECTIONS directive + !$omp end sections + + !$omp parallel sections + !ERROR: NOWAIT clause is not allowed on the END PARALLEL SECTIONS directive + !$omp end parallel sections nowait + ! 2.7.3 single-clause -> private-clause | ! firstprivate-clause ! end-single-clause -> copyprivate-clause |