}
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);
}
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()) {
break;
default:;
}
- if (auto error{scope.set_importKind(kind)}) {
+ if (auto error{scope.SetImportKind(kind)}) {
Say(std::move(*error));
}
for (auto &name : x.names) {
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);
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;
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
// 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 &);
// 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 &);