From 5776003259cb83e5b4794358818ac84621ee77dd Mon Sep 17 00:00:00 2001 From: David Truby Date: Tue, 17 Sep 2019 09:53:27 +0100 Subject: [PATCH] [flang] Corrected check for required OpenMP clauses Original-commit: flang-compiler/f18@ce3ec50c3f01785f8bc0f92f1a7f6b65b2e52973 Reviewed-on: https://github.com/flang-compiler/f18/pull/748 Tree-same-pre-rewrite: false --- flang/lib/semantics/check-omp-structure.cc | 16 +++++++++------- flang/lib/semantics/check-omp-structure.h | 2 -- flang/test/semantics/omp-device-constructs.f90 | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/flang/lib/semantics/check-omp-structure.cc b/flang/lib/semantics/check-omp-structure.cc index e5d7fdcced07..28f39cf53f27 100644 --- a/flang/lib/semantics/check-omp-structure.cc +++ b/flang/lib/semantics/check-omp-structure.cc @@ -437,9 +437,8 @@ void OmpStructureChecker::Enter(const parser::OpenMPBlockConstruct &x) { OmpClauseSet allowed{ OmpClause::IF, OmpClause::MAP, OmpClause::USE_DEVICE_PTR}; SetContextAllowed(allowed); - OmpClauseSet allowedOnce{OmpClause::DEVICE}; - SetContextAllowedOnce(allowedOnce); - SetContextRequired(OmpClauseSet{OmpClause::MAP}); + SetContextAllowedOnce({OmpClause::DEVICE}); + SetContextRequired({OmpClause::MAP}); } break; default: // TODO others @@ -557,7 +556,7 @@ void OmpStructureChecker::Enter( SetContextAllowed(allowed); OmpClauseSet allowedOnce{OmpClause::DEVICE, OmpClause::IF}; SetContextAllowedOnce(allowedOnce); - SetContextRequired(OmpClauseSet{OmpClause::MAP}); + SetContextRequired({OmpClause::MAP}); } break; case parser::OmpSimpleStandaloneDirective::Directive::TargetExitData: { // 2.10.3 target-exit-data @@ -566,7 +565,7 @@ void OmpStructureChecker::Enter( SetContextAllowed(allowed); OmpClauseSet allowedOnce{OmpClause::DEVICE, OmpClause::IF}; SetContextAllowedOnce(allowedOnce); - SetContextRequired(OmpClauseSet{OmpClause::MAP}); + SetContextRequired({OmpClause::MAP}); } break; case parser::OmpSimpleStandaloneDirective::Directive::TargetUpdate: { // 2.10.5 target-update @@ -731,6 +730,9 @@ void OmpStructureChecker::Leave(const parser::OmpClauseList &) { } } } + + GetContext().requiredClauses.IterateOverMembers( + [this](OmpClause c) { CheckRequired(c); }); } void OmpStructureChecker::Enter(const parser::OmpClause &x) { @@ -941,7 +943,7 @@ void OmpStructureChecker::Enter(const parser::OmpMapClause &x) { if (type != Type::To && type != Type::From && type != Type::Tofrom && type != Type::Alloc) { context_.Say(GetContext().clauseSource, - "Only the TO, FROM, TOFROM or ALLOC map types are permitted " + "Only the TO, FROM, TOFROM, or ALLOC map types are permitted " "for MAP clauses on the %s directive"_err_en_US, ContextDirectiveAsFortran()); } @@ -957,7 +959,7 @@ void OmpStructureChecker::Enter(const parser::OmpMapClause &x) { case OmpDirective::TARGET_EXIT_DATA: { if (type != Type::Delete && type != Type::Release && type != Type::From) { context_.Say(GetContext().clauseSource, - "Only the FROM, RELEASE or DELETE map types are permitted " + "Only the FROM, RELEASE, or DELETE map types are permitted " "for MAP clauses on the %s directive"_err_en_US, ContextDirectiveAsFortran()); } diff --git a/flang/lib/semantics/check-omp-structure.h b/flang/lib/semantics/check-omp-structure.h index 574facdf4ca4..a2c0f5040d51 100644 --- a/flang/lib/semantics/check-omp-structure.h +++ b/flang/lib/semantics/check-omp-structure.h @@ -152,8 +152,6 @@ private: // collected information for END directive void ResetPartialContext(const parser::CharBlock &source) { CHECK(!ompContext_.empty()); - GetContext().requiredClauses.IterateOverMembers( - [this](OmpClause c) { CheckRequired(c); }); SetContextDirectiveSource(source); GetContext().allowedClauses = {}; GetContext().allowedOnceClauses = {}; diff --git a/flang/test/semantics/omp-device-constructs.f90 b/flang/test/semantics/omp-device-constructs.f90 index 8fb37d5c8fba..90a12f7ee781 100644 --- a/flang/test/semantics/omp-device-constructs.f90 +++ b/flang/test/semantics/omp-device-constructs.f90 @@ -117,7 +117,7 @@ program main enddo !$omp end target - !ERROR: Only the TO, FROM, TOFROM or ALLOC map types are permitted for MAP clauses on the TARGET directive + !ERROR: Only the TO, FROM, TOFROM, or ALLOC map types are permitted for MAP clauses on the TARGET directive !$omp target map(delete:a) do i = 1, N a = 3.14 @@ -148,6 +148,6 @@ program main !ERROR: At most one DEVICE clause can appear on the TARGET EXIT DATA directive !$omp target exit data map(from:a) device(0) device(1) - !ERROR: Only the FROM, RELEASE or DELETE map types are permitted for MAP clauses on the TARGET EXIT DATA directive + !ERROR: Only the FROM, RELEASE, or DELETE map types are permitted for MAP clauses on the TARGET EXIT DATA directive !$omp target exit data map(to:a) end program main