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.cpp59
1 files changed, 38 insertions, 21 deletions
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 628068f..deb57e0 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -415,6 +415,18 @@ public:
return true;
}
+ bool Pre(const parser::SpecificationPart &) {
+ partStack_.push_back(PartKind::SpecificationPart);
+ return true;
+ }
+ void Post(const parser::SpecificationPart &) { partStack_.pop_back(); }
+
+ bool Pre(const parser::ExecutionPart &) {
+ partStack_.push_back(PartKind::ExecutionPart);
+ return true;
+ }
+ void Post(const parser::ExecutionPart &) { partStack_.pop_back(); }
+
bool Pre(const parser::InternalSubprogram &) {
// Clear the labels being tracked in the previous scope
ClearLabels();
@@ -639,8 +651,7 @@ public:
bool Pre(const parser::OpenMPThreadprivate &);
void Post(const parser::OpenMPThreadprivate &) { PopContext(); }
- bool Pre(const parser::OpenMPDeclarativeAllocate &);
- void Post(const parser::OpenMPDeclarativeAllocate &) { PopContext(); }
+ bool Pre(const parser::OmpAllocateDirective &);
bool Pre(const parser::OpenMPAssumeConstruct &);
void Post(const parser::OpenMPAssumeConstruct &) { PopContext(); }
@@ -651,9 +662,6 @@ public:
bool Pre(const parser::OpenMPDispatchConstruct &);
void Post(const parser::OpenMPDispatchConstruct &) { PopContext(); }
- bool Pre(const parser::OpenMPExecutableAllocate &);
- void Post(const parser::OpenMPExecutableAllocate &);
-
bool Pre(const parser::OpenMPAllocatorsConstruct &);
void Post(const parser::OpenMPAllocatorsConstruct &);
@@ -998,6 +1006,14 @@ private:
targetLabels_;
parser::CharBlock currentStatementSource_;
+ enum class PartKind : int {
+ // There are also other "parts", such as internal-subprogram-part, etc,
+ // but we're keeping track of these two for now.
+ SpecificationPart,
+ ExecutionPart,
+ };
+ std::vector<PartKind> partStack_;
+
void AddAllocateName(const parser::Name *&object) {
allocateNames_.push_back(object);
}
@@ -2558,10 +2574,24 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPThreadprivate &x) {
return true;
}
-bool OmpAttributeVisitor::Pre(const parser::OpenMPDeclarativeAllocate &x) {
+bool OmpAttributeVisitor::Pre(const parser::OmpAllocateDirective &x) {
PushContext(x.source, llvm::omp::Directive::OMPD_allocate);
- const auto &list{std::get<parser::OmpObjectList>(x.t)};
- ResolveOmpObjectList(list, Symbol::Flag::OmpDeclarativeAllocateDirective);
+ assert(!partStack_.empty() && "Misplaced directive");
+
+ auto ompFlag{partStack_.back() == PartKind::SpecificationPart
+ ? Symbol::Flag::OmpDeclarativeAllocateDirective
+ : Symbol::Flag::OmpExecutableAllocateDirective};
+
+ parser::omp::OmpAllocateInfo info{parser::omp::SplitOmpAllocate(x)};
+ for (const parser::OmpAllocateDirective *ad : info.dirs) {
+ for (const parser::OmpArgument &arg : ad->BeginDir().Arguments().v) {
+ if (auto *object{omp::GetArgumentObject(arg)}) {
+ ResolveOmpObject(*object, ompFlag);
+ }
+ }
+ }
+
+ PopContext();
return false;
}
@@ -2580,15 +2610,6 @@ bool OmpAttributeVisitor::Pre(const parser::OpenMPDispatchConstruct &x) {
return true;
}
-bool OmpAttributeVisitor::Pre(const parser::OpenMPExecutableAllocate &x) {
- PushContext(x.source, llvm::omp::Directive::OMPD_allocate);
- const auto &list{std::get<std::optional<parser::OmpObjectList>>(x.t)};
- if (list) {
- ResolveOmpObjectList(*list, Symbol::Flag::OmpExecutableAllocateDirective);
- }
- return true;
-}
-
bool OmpAttributeVisitor::Pre(const parser::OpenMPAllocatorsConstruct &x) {
const parser::OmpDirectiveSpecification &dirSpec{x.BeginDir()};
PushContext(x.source, dirSpec.DirId());
@@ -2660,10 +2681,6 @@ bool OmpAttributeVisitor::IsNestedInDirective(llvm::omp::Directive directive) {
return false;
}
-void OmpAttributeVisitor::Post(const parser::OpenMPExecutableAllocate &x) {
- PopContext();
-}
-
void OmpAttributeVisitor::Post(const parser::OpenMPAllocatorsConstruct &x) {
PopContext();
}