class MessageHandler;
static GenericSpec MapGenericSpec(const parser::GenericSpec &);
-static bool IsModule(const Scope &);
// ImplicitRules maps initial character of identifier to the DeclTypeSpec
// representing the implicit type; std::nullopt if none.
}
bool DeclarationVisitor::Pre(const parser::PrivateStmt &x) {
- if (!IsModule(currScope().parent())) {
+ if (!currScope().parent().IsModule()) {
Say("PRIVATE is only allowed in a derived type that is"
" in a module"_err_en_US); // C766
} else if (derivedTypeInfo_.sawContains) {
derivedTypeInfo_.privateComps = true;
} else {
Say("PRIVATE may not appear more than once in"
- " derived type components"_err_en_US); // C738
+ " derived type components"_en_US); // C738
}
return false;
}
// Check C896 and C899: where IMPORT statements are allowed
switch (scope.kind()) {
case Scope::Kind::Module:
- if (IsModule(scope)) {
+ if (scope.IsModule()) {
Say("IMPORT is not allowed in a module scoping unit"_err_en_US);
return false;
} else if (x.kind == common::ImportKind::None) {
genericSpec.u);
}
-// Is this a scope for a module (and not a submodule)?
-static bool IsModule(const Scope &scope) {
- return scope.kind() == Scope::Kind::Module &&
- !scope.symbol()->get<ModuleDetails>().isSubmodule();
-}
-
static void PutIndent(std::ostream &os, int indent) {
for (int i = 0; i < indent; ++i) {
os << " ";
Symbols<1024> Scope::allSymbols;
+bool Scope::IsModule() const {
+ return kind_ == Kind::Module && !symbol_->get<ModuleDetails>().isSubmodule();
+}
+
Scope &Scope::MakeScope(Kind kind, Symbol *symbol) {
children_.emplace_back(*this, kind, symbol);
return children_.back();