aboutsummaryrefslogtreecommitdiff
path: root/flang/lib/Semantics/resolve-directives.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'flang/lib/Semantics/resolve-directives.cpp')
-rw-r--r--flang/lib/Semantics/resolve-directives.cpp41
1 files changed, 25 insertions, 16 deletions
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 4c3e509..bb28cfb 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -378,7 +378,7 @@ public:
bool Pre(const parser::OpenMPBlockConstruct &);
void Post(const parser::OpenMPBlockConstruct &);
- void Post(const parser::OmpBeginBlockDirective &) {
+ void Post(const parser::OmpBeginDirective &x) {
GetContext().withinConstruct = true;
}
@@ -519,6 +519,9 @@ public:
bool Pre(const parser::OpenMPDeclarativeAllocate &);
void Post(const parser::OpenMPDeclarativeAllocate &) { PopContext(); }
+ bool Pre(const parser::OpenMPAtomicConstruct &);
+ void Post(const parser::OpenMPAtomicConstruct &) { PopContext(); }
+
bool Pre(const parser::OpenMPDispatchConstruct &);
void Post(const parser::OpenMPDispatchConstruct &) { PopContext(); }
@@ -1545,6 +1548,7 @@ void AccAttributeVisitor::Post(const parser::AccDefaultClause &x) {
void AccAttributeVisitor::Post(const parser::Name &name) {
auto *symbol{name.symbol};
if (symbol && !dirContext_.empty() && GetContext().withinConstruct) {
+ symbol = &symbol->GetUltimate();
if (!symbol->owner().IsDerivedType() && !symbol->has<ProcEntityDetails>() &&
!symbol->has<SubprogramDetails>() && !IsObjectWithDSA(*symbol)) {
if (Symbol * found{currScope().FindSymbol(name.source)}) {
@@ -1553,8 +1557,7 @@ void AccAttributeVisitor::Post(const parser::Name &name) {
} else if (GetContext().defaultDSA == Symbol::Flag::AccNone) {
// 2.5.14.
context_.Say(name.source,
- "The DEFAULT(NONE) clause requires that '%s' must be listed in "
- "a data-mapping clause"_err_en_US,
+ "The DEFAULT(NONE) clause requires that '%s' must be listed in a data-mapping clause"_err_en_US,
symbol->name());
}
}
@@ -1698,9 +1701,9 @@ static std::string ScopeSourcePos(const Fortran::semantics::Scope &scope);
#endif
bool OmpAttributeVisitor::Pre(const parser::OpenMPBlockConstruct &x) {
- const auto &beginBlockDir{std::get<parser::OmpBeginBlockDirective>(x.t)};
- const auto &beginDir{std::get<parser::OmpBlockDirective>(beginBlockDir.t)};
- switch (beginDir.v) {
+ const parser::OmpDirectiveSpecification &dirSpec{x.BeginDir()};
+ llvm::omp::Directive dirId{dirSpec.DirId()};
+ switch (dirId) {
case llvm::omp::Directive::OMPD_masked:
case llvm::omp::Directive::OMPD_parallel_masked:
case llvm::omp::Directive::OMPD_master:
@@ -1718,15 +1721,15 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPBlockConstruct &x) {
case llvm::omp::Directive::OMPD_parallel_workshare:
case llvm::omp::Directive::OMPD_target_teams:
case llvm::omp::Directive::OMPD_target_parallel:
- PushContext(beginDir.source, beginDir.v);
+ PushContext(dirSpec.source, dirId);
break;
default:
// TODO others
break;
}
- if (beginDir.v == llvm::omp::Directive::OMPD_master ||
- beginDir.v == llvm::omp::Directive::OMPD_parallel_master)
- IssueNonConformanceWarning(beginDir.v, beginDir.source, 52);
+ if (dirId == llvm::omp::Directive::OMPD_master ||
+ dirId == llvm::omp::Directive::OMPD_parallel_master)
+ IssueNonConformanceWarning(dirId, dirSpec.source, 52);
ClearDataSharingAttributeObjects();
ClearPrivateDataSharingAttributeObjects();
ClearAllocateNames();
@@ -1734,9 +1737,9 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPBlockConstruct &x) {
}
void OmpAttributeVisitor::Post(const parser::OpenMPBlockConstruct &x) {
- const auto &beginBlockDir{std::get<parser::OmpBeginBlockDirective>(x.t)};
- const auto &beginDir{std::get<parser::OmpBlockDirective>(beginBlockDir.t)};
- switch (beginDir.v) {
+ const parser::OmpDirectiveSpecification &dirSpec{x.BeginDir()};
+ llvm::omp::Directive dirId{dirSpec.DirId()};
+ switch (dirId) {
case llvm::omp::Directive::OMPD_masked:
case llvm::omp::Directive::OMPD_master:
case llvm::omp::Directive::OMPD_parallel_masked:
@@ -2152,7 +2155,8 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPDeclareTargetConstruct &x) {
ResolveOmpObjectList(linkClause->v, Symbol::Flag::OmpDeclareTarget);
} else if (const auto *enterClause{
std::get_if<parser::OmpClause::Enter>(&clause.u)}) {
- ResolveOmpObjectList(enterClause->v, Symbol::Flag::OmpDeclareTarget);
+ ResolveOmpObjectList(std::get<parser::OmpObjectList>(enterClause->v.t),
+ Symbol::Flag::OmpDeclareTarget);
}
}
}
@@ -2184,6 +2188,11 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPDeclarativeAllocate &x) {
return false;
}
+bool OmpAttributeVisitor::Pre(const parser::OpenMPAtomicConstruct &x) {
+ PushContext(x.source, llvm::omp::Directive::OMPD_atomic);
+ return true;
+}
+
bool OmpAttributeVisitor::Pre(const parser::OpenMPDispatchConstruct &x) {
PushContext(x.source, llvm::omp::Directive::OMPD_dispatch);
return true;
@@ -2201,7 +2210,7 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPExecutableAllocate &x) {
}
bool OmpAttributeVisitor::Pre(const parser::OpenMPAllocatorsConstruct &x) {
- auto &dirSpec{std::get<parser::OmpDirectiveSpecification>(x.t)};
+ const parser::OmpDirectiveSpecification &dirSpec{x.BeginDir()};
PushContext(x.source, dirSpec.DirId());
for (const auto &clause : dirSpec.Clauses().v) {
@@ -2287,7 +2296,7 @@ void OmpAttributeVisitor::Post(const parser::OpenMPExecutableAllocate &x) {
}
void OmpAttributeVisitor::Post(const parser::OpenMPAllocatorsConstruct &x) {
- auto &dirSpec{std::get<parser::OmpDirectiveSpecification>(x.t)};
+ const parser::OmpDirectiveSpecification &dirSpec{x.BeginDir()};
auto &block{std::get<parser::Block>(x.t)};
omp::SourcedActionStmt action{omp::GetActionStmt(block)};