Skip to content

Commit

Permalink
Revert "[flang] OpenMP allocate directive parse tree fix"
Browse files Browse the repository at this point in the history
This reverts commit eaf7d97.
Arcanist stripped co-author data from initial commit.
  • Loading branch information
EthanLuisMcDonough committed May 5, 2023
1 parent c501aa8 commit c899598
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 144 deletions.
8 changes: 0 additions & 8 deletions flang/lib/Parser/unparse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2325,14 +2325,6 @@ class UnparseVisitor {
EndOpenMP();
}
void Unparse(const OpenMPExecutableAllocate &x) {
const auto &fields =
std::get<std::optional<std::list<parser::OpenMPDeclarativeAllocate>>>(
x.t);
if (fields) {
for (const auto &decl : *fields) {
Walk(decl);
}
}
BeginOpenMP();
Word("!$OMP ALLOCATE");
Walk(" (", std::get<std::optional<OmpObjectList>>(x.t), ")");
Expand Down
45 changes: 1 addition & 44 deletions flang/lib/Semantics/canonicalize-omp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
// 1. move structured DoConstruct and OmpEndLoopDirective into
// OpenMPLoopConstruct. Compilation will not proceed in case of errors
// after this pass.
// 2. Associate declarative OMP allocation directives with their
// respective executable allocation directive
// 3. TBD
// 2. TBD
namespace Fortran::semantics {

using namespace parser::literals;
Expand Down Expand Up @@ -48,8 +46,6 @@ class CanonicalizationOfOmp {
} // Block list
}

void Post(parser::ExecutionPart &body) { RewriteOmpAllocations(body); }

private:
template <typename T> T *GetConstructIf(parser::ExecutionPartConstruct &x) {
if (auto *y{std::get_if<parser::ExecutableConstruct>(&x.u)}) {
Expand All @@ -60,15 +56,6 @@ class CanonicalizationOfOmp {
return nullptr;
}

template <typename T> T *GetOmpIf(parser::ExecutionPartConstruct &x) {
if (auto *construct{GetConstructIf<parser::OpenMPConstruct>(x)}) {
if (auto *omp{std::get_if<T>(&construct->u)}) {
return omp;
}
}
return nullptr;
}

void RewriteOpenMPLoopConstruct(parser::OpenMPLoopConstruct &x,
parser::Block &block, parser::Block::iterator it) {
// Check the sequence of DoConstruct and OmpEndLoopDirective
Expand Down Expand Up @@ -119,36 +106,6 @@ class CanonicalizationOfOmp {
parser::ToUpperCaseLetters(dir.source.ToString()));
}

void RewriteOmpAllocations(parser::ExecutionPart &body) {
// Rewrite leading declarative allocations so they are nested
// within their respective executable allocate directive
//
// Original:
// ExecutionPartConstruct -> OpenMPDeclarativeAllocate
// ExecutionPartConstruct -> OpenMPDeclarativeAllocate
// ExecutionPartConstruct -> OpenMPExecutableAllocate
//
// After rewriting:
// ExecutionPartConstruct -> OpenMPExecutableAllocate
// ExecutionPartConstruct -> OpenMPDeclarativeAllocate
// ExecutionPartConstruct -> OpenMPDeclarativeAllocate
for (auto it = body.v.rbegin(); it != body.v.rend();) {
if (auto *exec = GetOmpIf<parser::OpenMPExecutableAllocate>(*(it++))) {
parser::OpenMPDeclarativeAllocate *decl;
std::list<parser::OpenMPDeclarativeAllocate> subAllocates;
while (it != body.v.rend() &&
(decl = GetOmpIf<parser::OpenMPDeclarativeAllocate>(*it))) {
subAllocates.push_front(std::move(*decl));
it = decltype(it)(body.v.erase(std::next(it).base()));
}
if (!subAllocates.empty()) {
std::get<std::optional<std::list<parser::OpenMPDeclarativeAllocate>>>(
exec->t) = {std::move(subAllocates)};
}
}
}
}

parser::Messages &messages_;
};

Expand Down
3 changes: 1 addition & 2 deletions flang/lib/Semantics/resolve-directives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1691,8 +1691,7 @@ void OmpAttributeVisitor::ResolveOmpObject(
}
}
if (ompFlag == Symbol::Flag::OmpDeclarativeAllocateDirective &&
IsAllocatable(*symbol) &&
!IsNestedInDirective(llvm::omp::Directive::OMPD_allocate)) {
IsAllocatable(*symbol)) {
context_.Say(designator.source,
"List items specified in the ALLOCATE directive must not "
"have the ALLOCATABLE attribute unless the directive is "
Expand Down
47 changes: 0 additions & 47 deletions flang/test/Parser/OpenMP/allocate-tree-spec-part.f90

This file was deleted.

43 changes: 0 additions & 43 deletions flang/test/Parser/OpenMP/allocate-tree.f90

This file was deleted.

0 comments on commit c899598

Please sign in to comment.