[flang] Address review comments

Original-commit: flang-compiler/f18@c30cbc8158
Reviewed-on: https://github.com/flang-compiler/f18/pull/167
Tree-same-pre-rewrite: false
This commit is contained in:
Tim Keith 2018-08-23 11:24:12 -07:00
parent d82ec6eb23
commit 364aed2109
3 changed files with 9 additions and 9 deletions

View File

@ -1330,7 +1330,7 @@ bool ModuleVisitor::Pre(const parser::Submodule &x) {
}
PushScope(*parentScope); // submodule is hosted in parent
auto &symbol{BeginModule(name, true, subpPart)};
if (!ancestor->AddSubmodule(name, &currScope())) {
if (!ancestor->AddSubmodule(name, currScope())) {
Say(name, "Module '%s' already has a submodule named '%s'"_err_en_US,
ancestorName, name);
}
@ -2151,7 +2151,7 @@ void ResolveNamesVisitor::Post(const parser::CallStmt &) {
bool ResolveNamesVisitor::Pre(const parser::ImportStmt &x) {
auto kind{MapImportKind(x.kind)};
auto &scope{currScope()};
// Check C896 and C899
// Check C896 and C899: where IMPORT statements are allowed
switch (scope.kind()) {
case Scope::Kind::Module:
if (!scope.symbol()->get<ModuleDetails>().isSubmodule()) {
@ -2173,7 +2173,7 @@ bool ResolveNamesVisitor::Pre(const parser::ImportStmt &x) {
break;
default:;
}
if (auto error{scope.set_importKind(kind)}) {
if (auto error{scope.SetImportKind(kind)}) {
Say(std::move(*error));
}
for (auto &name : x.names) {

View File

@ -66,8 +66,8 @@ Scope *Scope::FindSubmodule(const SourceName &name) const {
return it->second;
}
}
bool Scope::AddSubmodule(const SourceName &name, Scope *submodule) {
return submodules_.emplace(name, submodule).second;
bool Scope::AddSubmodule(const SourceName &name, Scope &submodule) {
return submodules_.emplace(name, &submodule).second;
}
DerivedTypeSpec &Scope::MakeDerivedTypeSpec(const SourceName &name) {
derivedTypeSpecs_.emplace_back(name);
@ -88,7 +88,7 @@ Scope::ImportKind Scope::importKind() const {
return ImportKind::Default;
}
std::optional<parser::MessageFixedText> Scope::set_importKind(ImportKind kind) {
std::optional<parser::MessageFixedText> Scope::SetImportKind(ImportKind kind) {
if (!importKind_.has_value()) {
importKind_ = kind;
return std::nullopt;
@ -96,7 +96,7 @@ std::optional<parser::MessageFixedText> Scope::set_importKind(ImportKind kind) {
std::optional<parser::MessageFixedText> error;
bool hasNone{kind == ImportKind::None || *importKind_ == ImportKind::None};
bool hasAll{kind == ImportKind::All || *importKind_ == ImportKind::All};
// Check C8100 and C898
// Check C8100 and C898: constraints on multiple IMPORT statements
if (hasNone || hasAll) {
return hasNone
? "IMPORT,NONE must be the only IMPORT statement in a scope"_err_en_US

View File

@ -117,7 +117,7 @@ public:
// For Module scope, maintain a mapping of all submodule scopes with this
// module as its ancestor module. AddSubmodule returns false if already there.
Scope *FindSubmodule(const SourceName &) const;
bool AddSubmodule(const SourceName &, Scope *);
bool AddSubmodule(const SourceName &, Scope &);
DerivedTypeSpec &MakeDerivedTypeSpec(const SourceName &);
@ -131,7 +131,7 @@ public:
// Set the kind of imports from host into this scope.
// Return an error message for incompatible kinds.
std::optional<parser::MessageFixedText> set_importKind(ImportKind);
std::optional<parser::MessageFixedText> SetImportKind(ImportKind);
bool add_importName(const SourceName &);