[flang] Corrected check for required OpenMP clauses

Original-commit: flang-compiler/f18@ce3ec50c3f
Reviewed-on: https://github.com/flang-compiler/f18/pull/748
Tree-same-pre-rewrite: false
This commit is contained in:
David Truby 2019-09-17 09:53:27 +01:00
parent 7c09d48218
commit 5776003259
3 changed files with 11 additions and 11 deletions

View File

@ -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());
}

View File

@ -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 = {};

View File

@ -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