Skip to content

Commit

Permalink
[flang] Corrections for map semantics to match coding style
Browse files Browse the repository at this point in the history
Original-commit: flang-compiler/f18@f2d97c3
Reviewed-on: flang-compiler/f18#748
Tree-same-pre-rewrite: false
  • Loading branch information
DavidTruby committed Sep 27, 2019
1 parent d3e8c76 commit 7c09d48
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 5 additions & 6 deletions flang/lib/semantics/check-omp-structure.cc
Expand Up @@ -131,8 +131,7 @@ void OmpStructureChecker::CheckAllowed(OmpClause type) {
}

void OmpStructureChecker::CheckRequired(OmpClause c) {
auto *clause{FindClause(c)};
if (!clause) {
if (!FindClause(c)) {
context_.Say(GetContext().directiveSource,
"At least one %s clause must appear on the %s directive"_err_en_US,
EnumToString(c), ContextDirectiveAsFortran());
Expand Down Expand Up @@ -935,30 +934,30 @@ void OmpStructureChecker::Enter(const parser::OmpMapClause &x) {
CheckAllowed(OmpClause::MAP);
if (const auto &maptype{std::get<std::optional<parser::OmpMapType>>(x.t)}) {
using Type = parser::OmpMapType::Type;
const Type &type = std::get<Type>(maptype->t);
const Type &type{std::get<Type>(maptype->t)};
switch (GetContext().directive) {
case OmpDirective::TARGET:
case OmpDirective::TARGET_DATA: {
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());
}
} break;
case OmpDirective::TARGET_ENTER_DATA: {
if (type != Type::To && type != Type::Alloc) {
context_.Say(GetContext().clauseSource,
"Only the to or alloc map types are permitted "
"Only the TO or ALLOC map types are permitted "
"for MAP clauses on the %s directive"_err_en_US,
ContextDirectiveAsFortran());
}
} break;
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());
}
Expand Down
6 changes: 3 additions & 3 deletions flang/test/semantics/omp-device-constructs.f90
Expand Up @@ -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
Expand All @@ -140,14 +140,14 @@ program main
!ERROR: At most one IF clause can appear on the TARGET ENTER DATA directive
!$omp target enter data map(to:a) if(.true.) if(.false.)

!ERROR: Only the to or alloc map types are permitted for MAP clauses on the TARGET ENTER DATA directive
!ERROR: Only the TO or ALLOC map types are permitted for MAP clauses on the TARGET ENTER DATA directive
!$omp target enter data map(from:a)

!$omp target exit data map(delete:a)

!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

0 comments on commit 7c09d48

Please sign in to comment.