[flang-commits] [flang] 6395afa - [flang] Fix homonymous interface and procedure warning (#171696)

via flang-commits flang-commits at lists.llvm.org
Fri Jan 9 04:29:32 PST 2026


Author: Leandro Lupori
Date: 2026-01-09T09:29:27-03:00
New Revision: 6395afa535e9a05bc97ca7876fac1024de8ee17d

URL: https://github.com/llvm/llvm-project/commit/6395afa535e9a05bc97ca7876fac1024de8ee17d
DIFF: https://github.com/llvm/llvm-project/commit/6395afa535e9a05bc97ca7876fac1024de8ee17d.diff

LOG: [flang] Fix homonymous interface and procedure warning (#171696)

When emitting an homonymous generic interface and procedure warning,
the source locations of the interface and the procedure were being
compared to find the one that occurred later in the source file.

The problem is that they could be in different source/module files,
which makes the comparison invalid.

Fix it by using parser::AllCookedSources::Precedes() instead, that
correctly handle names in different source files.

Added: 
    

Modified: 
    flang/lib/Semantics/resolve-names.cpp

Removed: 
    


################################################################################
diff  --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 8086e43b90f20..527be8645ff81 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -4540,8 +4540,9 @@ void InterfaceVisitor::CheckGenericProcedures(Symbol &generic) {
   auto &details{generic.get<GenericDetails>()};
   if (auto *proc{details.CheckSpecific()}) {
     context().Warn(common::UsageWarning::HomonymousSpecific,
-        proc->name().begin() > generic.name().begin() ? proc->name()
-                                                      : generic.name(),
+        context().allCookedSources().Precedes(generic.name(), proc->name())
+            ? proc->name()
+            : generic.name(),
         "'%s' should not be the name of both a generic interface and a procedure unless it is a specific procedure of the generic"_warn_en_US,
         generic.name());
   }


        


More information about the flang-commits mailing list