forked from OSchip/llvm-project
[flang] prep for review
Original-commit: flang-compiler/f18@41f11f4fa0 Reviewed-on: https://github.com/flang-compiler/f18/pull/638 Tree-same-pre-rewrite: false
This commit is contained in:
parent
fca50c0822
commit
699b499469
|
@ -5001,14 +5001,11 @@ void DeclarationVisitor::PointerInitialization(
|
||||||
Symbol &ultimate{name.symbol->GetUltimate()};
|
Symbol &ultimate{name.symbol->GetUltimate()};
|
||||||
if (IsPointer(ultimate)) {
|
if (IsPointer(ultimate)) {
|
||||||
if (auto *details{ultimate.detailsIf<ObjectEntityDetails>()}) {
|
if (auto *details{ultimate.detailsIf<ObjectEntityDetails>()}) {
|
||||||
// Initialization may have already been performed in the
|
CHECK(!details->init().has_value());
|
||||||
// case of a pointer component in a parameterized derived type.
|
Walk(target);
|
||||||
if (!details->init().has_value()) {
|
if (MaybeExpr expr{EvaluateExpr(target)}) {
|
||||||
Walk(target);
|
CheckInitialDataTarget(ultimate, *expr, target.value().source);
|
||||||
if (MaybeExpr expr{EvaluateExpr(target)}) {
|
details->set_init(std::move(*expr));
|
||||||
CheckInitialDataTarget(ultimate, *expr, target.value().source);
|
|
||||||
details->set_init(std::move(*expr));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -5022,16 +5019,15 @@ void DeclarationVisitor::PointerInitialization(
|
||||||
Symbol &ultimate{name.symbol->GetUltimate()};
|
Symbol &ultimate{name.symbol->GetUltimate()};
|
||||||
if (IsProcedurePointer(ultimate)) {
|
if (IsProcedurePointer(ultimate)) {
|
||||||
auto &details{ultimate.get<ProcEntityDetails>()};
|
auto &details{ultimate.get<ProcEntityDetails>()};
|
||||||
if (!details.init().has_value()) {
|
CHECK(!details.init().has_value());
|
||||||
Walk(target);
|
Walk(target);
|
||||||
if (const auto *targetName{std::get_if<parser::Name>(&target.u)}) {
|
if (const auto *targetName{std::get_if<parser::Name>(&target.u)}) {
|
||||||
CheckInitialProcTarget(ultimate, *targetName, name.source);
|
CheckInitialProcTarget(ultimate, *targetName, name.source);
|
||||||
if (targetName->symbol != nullptr) {
|
if (targetName->symbol != nullptr) {
|
||||||
details.set_init(*targetName->symbol);
|
details.set_init(*targetName->symbol);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
details.set_init(nullptr); // NULL()
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
details.set_init(nullptr); // NULL()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Say(name,
|
Say(name,
|
||||||
|
@ -5537,9 +5533,7 @@ public:
|
||||||
explicit DeferredPointerInitializationVisitor(ResolveNamesVisitor &resolver)
|
explicit DeferredPointerInitializationVisitor(ResolveNamesVisitor &resolver)
|
||||||
: resolver_{resolver} {}
|
: resolver_{resolver} {}
|
||||||
|
|
||||||
void Walk(const parser::SpecificationPart &spec) {
|
template<typename A> void Walk(const A &x) { parser::Walk(x, *this); }
|
||||||
parser::Walk(spec, *this);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename A> bool Pre(const A &) { return true; }
|
template<typename A> bool Pre(const A &) { return true; }
|
||||||
template<typename A> void Post(const A &) {}
|
template<typename A> void Post(const A &) {}
|
||||||
|
@ -5600,14 +5594,19 @@ private:
|
||||||
bool pushedScope_{false};
|
bool pushedScope_{false};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Perform checks that need to happen after all of the specification parts
|
// Perform checks and completions that need to happen after all of
|
||||||
// but before any of the execution parts.
|
// the specification parts but before any of the execution parts.
|
||||||
void ResolveNamesVisitor::FinishSpecificationParts(const ProgramTree &node) {
|
void ResolveNamesVisitor::FinishSpecificationParts(const ProgramTree &node) {
|
||||||
if (!node.scope()) {
|
if (!node.scope()) {
|
||||||
return; // error occurred creating scope
|
return; // error occurred creating scope
|
||||||
}
|
}
|
||||||
SetScope(*node.scope());
|
SetScope(*node.scope());
|
||||||
|
// The initializers of pointers, pointer components, and non-deferred
|
||||||
|
// type-bound procedure bindings have not yet been traversed.
|
||||||
|
// We do that now, when any (formerly) forward references that appear
|
||||||
|
// in those initializers will resolve to the right symbols.
|
||||||
DeferredPointerInitializationVisitor{*this}.Walk(node.spec());
|
DeferredPointerInitializationVisitor{*this}.Walk(node.spec());
|
||||||
|
DeferredPointerInitializationVisitor{*this}.Walk(node.exec()); // for BLOCK
|
||||||
for (auto &pair : currScope()) {
|
for (auto &pair : currScope()) {
|
||||||
Symbol &symbol{*pair.second};
|
Symbol &symbol{*pair.second};
|
||||||
if (const auto *details{symbol.detailsIf<GenericDetails>()}) {
|
if (const auto *details{symbol.detailsIf<GenericDetails>()}) {
|
||||||
|
@ -5616,6 +5615,9 @@ void ResolveNamesVisitor::FinishSpecificationParts(const ProgramTree &node) {
|
||||||
CheckExplicitInterface(symbol);
|
CheckExplicitInterface(symbol);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Finish the definitions of derived types and parameterized derived
|
||||||
|
// type instantiations. The original derived type definitions need to
|
||||||
|
// be finished before the instantiations can be.
|
||||||
for (Scope &childScope : currScope().children()) {
|
for (Scope &childScope : currScope().children()) {
|
||||||
if (childScope.IsDerivedType() && childScope.symbol()) {
|
if (childScope.IsDerivedType() && childScope.symbol()) {
|
||||||
FinishDerivedTypeDefinition(childScope);
|
FinishDerivedTypeDefinition(childScope);
|
||||||
|
|
Loading…
Reference in New Issue