}
Kind kind() const { return kind_; }
bool IsGlobal() const { return kind_ == Kind::Global; }
- bool IsModule() const; // only module, not submodule
- bool IsSubmodule() const;
+ bool IsModule() const {
+ return kind_ == Kind::Module &&
+ !symbol_->get<ModuleDetails>().isSubmodule();
+ }
+ bool IsSubmodule() const {
+ return kind_ == Kind::Module && symbol_->get<ModuleDetails>().isSubmodule();
+ }
bool IsDerivedType() const { return kind_ == Kind::DerivedType; }
bool IsStmtFunction() const;
bool IsParameterizedDerivedType() const;
Result operator()(const CoarrayRef &) const { return "coindexed reference"; }
Result operator()(const semantics::Symbol &symbol) const {
- if (semantics::IsNamedConstant(symbol)) {
+ const auto &ultimate{symbol.GetUltimate()};
+ if (semantics::IsNamedConstant(ultimate) || ultimate.owner().IsModule() ||
+ ultimate.owner().IsSubmodule()) {
return std::nullopt;
- } else if (scope_.IsDerivedType() && IsVariableName(symbol)) { // C750, C754
+ } else if (scope_.IsDerivedType() &&
+ IsVariableName(ultimate)) { // C750, C754
return "derived type component or type parameter value not allowed to "
"reference variable '"s +
- symbol.name().ToString() + "'";
- } else if (IsDummy(symbol)) {
- if (symbol.attrs().test(semantics::Attr::OPTIONAL)) {
+ ultimate.name().ToString() + "'";
+ } else if (IsDummy(ultimate)) {
+ if (ultimate.attrs().test(semantics::Attr::OPTIONAL)) {
return "reference to OPTIONAL dummy argument '"s +
- symbol.name().ToString() + "'";
- } else if (symbol.attrs().test(semantics::Attr::INTENT_OUT)) {
+ ultimate.name().ToString() + "'";
+ } else if (ultimate.attrs().test(semantics::Attr::INTENT_OUT)) {
return "reference to INTENT(OUT) dummy argument '"s +
- symbol.name().ToString() + "'";
- } else if (symbol.has<semantics::ObjectEntityDetails>()) {
+ ultimate.name().ToString() + "'";
+ } else if (ultimate.has<semantics::ObjectEntityDetails>()) {
return std::nullopt;
} else {
return "dummy procedure argument";
}
- } else if (symbol.has<semantics::UseDetails>() ||
- symbol.has<semantics::HostAssocDetails>() ||
- symbol.owner().kind() == semantics::Scope::Kind::Module) {
- return std::nullopt;
} else if (const auto *object{
- symbol.detailsIf<semantics::ObjectEntityDetails>()}) {
+ ultimate.detailsIf<semantics::ObjectEntityDetails>()}) {
// TODO: what about EQUIVALENCE with data in COMMON?
// TODO: does this work for blank COMMON?
if (object->commonBlock()) {
}
for (const semantics::Scope *s{&scope_}; !s->IsGlobal();) {
s = &s->parent();
- if (s == &symbol.owner()) {
+ if (s == &ultimate.owner()) {
return std::nullopt;
}
}
- return "reference to local entity '"s + symbol.name().ToString() + "'";
+ return "reference to local entity '"s + ultimate.name().ToString() + "'";
}
Result operator()(const Component &x) const {