[flang-commits] [flang] [Flang][Semantics] Diagnose missing MODULE prefix in submodule procedures (PR #197173)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Thu Sep 3 07:04:09 PDT 2026
================
@@ -5976,6 +5976,26 @@ const Symbol *SubprogramVisitor::CheckExtantProc(
Symbol *SubprogramVisitor::PushSubprogramScope(const parser::Name &name,
Symbol::Flag subpFlag, const parser::LanguageBindingSpec *bindingSpec,
bool hasModulePrefix) {
+ if (!inInterfaceBlock() && currScope().IsSubmodule() && !hasModulePrefix) {
+ const Scope &parent{currScope().parent()};
+ if (parent.IsModule() || parent.IsSubmodule()) {
+ if (const Symbol *host{parent.FindSymbol(name.source)}) {
+ const Symbol &hostUlt{host->GetUltimate()};
+ const auto *hostSubp{hostUlt.detailsIf<SubprogramDetails>()};
+ if (hostSubp && hostSubp->isInterface() &&
+ hostUlt.attrs().test(Attr::MODULE)) {
+ context().messages().Warn(/*isInModuleFile=*/InModuleFile(),
----------------
eugeneepshteyn wrote:
A short comment on the context().messages().Warn(...) call explaining why it bypasses SemanticsContext::Warn (module-file scope-ancestry suppression) would protect it from a future "simplification" back to context().Warn — fold-integer.cpp carries such a comment at its analogous call.
https://github.com/llvm/llvm-project/pull/197173
More information about the flang-commits
mailing list