[flang] Added tofrom:scalar check for defaultmap clause

Original-commit: flang-compiler/f18@1025649b64
Reviewed-on: https://github.com/flang-compiler/f18/pull/719
Tree-same-pre-rewrite: false
This commit is contained in:
David Truby 2019-09-10 11:02:17 +01:00
parent 4b30ecf11c
commit 9527a18816
2 changed files with 23 additions and 4 deletions

View File

@ -396,8 +396,9 @@ void OmpStructureChecker::Enter(const parser::OpenMPBlockConstruct &x) {
// depend-clause
case parser::OmpBlockDirective::Directive::Target: {
PushContext(beginDir.source, OmpDirective::TARGET);
OmpClauseSet allowed{OmpClause::IF, OmpClause::PRIVATE, OmpClause::MAP,
OmpClause::DEPEND, OmpClause::FIRSTPRIVATE, OmpClause::IS_DEVICE_PTR};
OmpClauseSet allowed{OmpClause::IF, OmpClause::PRIVATE,
OmpClause::FIRSTPRIVATE, OmpClause::MAP, OmpClause::IS_DEVICE_PTR,
OmpClause::DEPEND};
SetContextAllowed(allowed);
OmpClauseSet allowedOnce{
OmpClause::DEVICE, OmpClause::DEFAULTMAP, OmpClause::NOWAIT};
@ -825,8 +826,14 @@ void OmpStructureChecker::Enter(const parser::OmpAlignedClause &x) {
void OmpStructureChecker::Enter(const parser::OmpDefaultClause &) {
CheckAllowed(OmpClause::DEFAULT);
}
void OmpStructureChecker::Enter(const parser::OmpDefaultmapClause &) {
void OmpStructureChecker::Enter(const parser::OmpDefaultmapClause &x) {
CheckAllowed(OmpClause::DEFAULTMAP);
using VariableCategory = parser::OmpDefaultmapClause::VariableCategory;
if (!std::get<std::optional<VariableCategory>>(x.t)) {
context_.Say(GetContext().clauseSource,
"The scalar VARIABLECATEGORY must be specified on the DEFAULTMAP "
"clause"_err_en_US);
}
}
void OmpStructureChecker::Enter(const parser::OmpDependClause &) {
CheckAllowed(OmpClause::DEPEND);

View File

@ -36,7 +36,6 @@ program main
enddo
!$omp end target
!ERROR: At most one DEVICE clause can appear on the TARGET directive
!$omp target device(0) device(1)
do i = 1, N
@ -51,6 +50,19 @@ program main
enddo
!$omp end target
!$omp target defaultmap(tofrom:scalar)
do i = 1, N
a = 3.14
enddo
!$omp end target
!ERROR: The scalar VARIABLECATEGORY must be specified on the DEFAULTMAP clause
!$omp target defaultmap(tofrom)
do i = 1, N
a = 3.14
enddo
!$omp end target
!ERROR: At most one DEFAULTMAP clause can appear on the TARGET directive
!$omp target defaultmap(tofrom:scalar) defaultmap(tofrom:scalar)
do i = 1, N