diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp --- a/flang/lib/Semantics/resolve-directives.cpp +++ b/flang/lib/Semantics/resolve-directives.cpp @@ -330,6 +330,9 @@ } void Post(const parser::OpenMPRequiresConstruct &) { PopContext(); } + bool Pre(const parser::OpenMPDeclareTargetConstruct &); + void Post(const parser::OpenMPDeclareTargetConstruct &) { PopContext(); } + bool Pre(const parser::OpenMPThreadprivate &); void Post(const parser::OpenMPThreadprivate &) { PopContext(); } @@ -1468,6 +1471,25 @@ return true; } +bool OmpAttributeVisitor::Pre(const parser::OpenMPDeclareTargetConstruct &x) { + PushContext(x.source, llvm::omp::Directive::OMPD_declare_target); + const auto &spec{std::get(x.t)}; + if (const auto *objectList{parser::Unwrap(spec.u)}) { + ResolveOmpObjectList(*objectList, Symbol::Flag::OmpDeclareTarget); + } else if (const auto *clauseList{ + parser::Unwrap(spec.u)}) { + for (const auto &clause : clauseList->v) { + if (const auto *toClause{std::get_if(&clause.u)}) { + ResolveOmpObjectList(toClause->v, Symbol::Flag::OmpDeclareTarget); + } else if (const auto *linkClause{ + std::get_if(&clause.u)}) { + ResolveOmpObjectList(linkClause->v, Symbol::Flag::OmpDeclareTarget); + } + } + } + return true; +} + bool OmpAttributeVisitor::Pre(const parser::OpenMPThreadprivate &x) { PushContext(x.source, llvm::omp::Directive::OMPD_threadprivate); const auto &list{std::get(x.t)};