Skip to content

Commit

Permalink
[flang] Better fix; clean up redundant utilities
Browse files Browse the repository at this point in the history
Original-commit: flang-compiler/f18@531db49
Reviewed-on: flang-compiler/f18#926
Tree-same-pre-rewrite: false
  • Loading branch information
klausler committed Jan 14, 2020
1 parent 294cae1 commit a3f4eed
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
18 changes: 11 additions & 7 deletions flang/lib/semantics/resolve-names.cc
Expand Up @@ -4617,14 +4617,18 @@ bool ConstructVisitor::Pre(const parser::DataStmtObject &x) {
common::visitors{
[&](const Indirection<parser::Variable> &y) {
Walk(y.value());
if (auto expr{AnalyzeExpr(context(), y)}) {
if (auto dataRef{evaluate::ExtractDataRef(*expr)}) {
const_cast<Symbol &>(dataRef->GetFirstSymbol())
.set(Symbol::Flag::InDataStmt);
// TODO check C875-C881 here?
} else {
// TODO C875 error: variable is not a designator
if (const auto *designator{
std::get_if<Indirection<parser::Designator>>(
&y.value().u)}) {
if (const parser::Name *
name{ResolveDesignator(designator->value())}) {
if (name->symbol) {
name->symbol->set(Symbol::Flag::InDataStmt);
}
}
// TODO check C874 - C881
} else {
// TODO report C875 error: variable is not a designator here?
}
},
[&](const parser::DataImpliedDo &y) {
Expand Down
21 changes: 4 additions & 17 deletions flang/lib/semantics/tools.cc
Expand Up @@ -22,25 +22,12 @@

namespace Fortran::semantics {

static const Symbol *FindCommonBlockInScope(
const Scope &scope, const Symbol &object) {
for (const auto &pair : scope.commonBlocks()) {
const Symbol &block{*pair.second};
if (IsCommonBlockContaining(block, object)) {
return &block;
}
}
return nullptr;
}

const Symbol *FindCommonBlockContaining(const Symbol &object) {
for (const Scope *scope{&object.owner()}; !scope->IsGlobal();
scope = &scope->parent()) {
if (const Symbol * block{FindCommonBlockInScope(*scope, object)}) {
return block;
}
if (const auto *details{object.detailsIf<ObjectEntityDetails>()}) {
return details->commonBlock();
} else {
return nullptr;
}
return nullptr;
}

const Scope *FindProgramUnitContaining(const Scope &start) {
Expand Down
1 change: 0 additions & 1 deletion flang/lib/semantics/tools.h
Expand Up @@ -73,7 +73,6 @@ bool IsIntrinsicConcat(
const evaluate::DynamicType &, int, const evaluate::DynamicType &, int);

bool IsGenericDefinedOp(const Symbol &);
bool IsCommonBlockContaining(const Symbol &block, const Symbol &object);
bool DoesScopeContain(const Scope *maybeAncestor, const Scope &maybeDescendent);
bool DoesScopeContain(const Scope *, const Symbol &);
bool IsUseAssociated(const Symbol &, const Scope &);
Expand Down

0 comments on commit a3f4eed

Please sign in to comment.