diff --git a/flang/lib/Semantics/check-declarations.cpp b/flang/lib/Semantics/check-declarations.cpp index 2c2866d590ae5..c3a333b5917d2 100644 --- a/flang/lib/Semantics/check-declarations.cpp +++ b/flang/lib/Semantics/check-declarations.cpp @@ -2395,6 +2395,10 @@ void CheckHelper::Check(const Scope &scope) { for (const auto &pair : scope) { Check(*pair.second); } + if (scope.IsSubmodule() && scope.symbol()) { + // Submodule names are not in their parent's scopes + Check(*scope.symbol()); + } for (const auto &pair : scope.commonBlocks()) { CheckCommonBlock(*pair.second); }