[flang-commits] [PATCH] D132686: [flang] Fix module file issue with renamed shadowed specific procedures
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Thu Aug 25 15:52:33 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG950a1618fd60: [flang] Fix module file issue with renamed shadowed specific procedures (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132686/new/
https://reviews.llvm.org/D132686
Files:
flang/lib/Semantics/resolve-names.cpp
flang/test/Semantics/modfile50.f90
Index: flang/test/Semantics/modfile50.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/modfile50.f90
@@ -0,0 +1,33 @@
+! RUN: %python %S/test_modfile.py %s %flang_fc1
+module m1
+ interface foo
+ module procedure foo
+ end interface
+ contains
+ subroutine foo
+ end subroutine
+end module
+module m2
+ use m1, bar => foo
+ interface baz
+ module procedure bar ! must not be replaced in module file with "foo"
+ end interface
+end module
+
+!Expect: m1.mod
+!module m1
+!interface foo
+!procedure::foo
+!end interface
+!contains
+!subroutine foo()
+!end
+!end
+
+!Expect: m2.mod
+!module m2
+!use m1,only:bar=>foo
+!interface baz
+!procedure::bar
+!end interface
+!end
Index: flang/lib/Semantics/resolve-names.cpp
===================================================================
--- flang/lib/Semantics/resolve-names.cpp
+++ flang/lib/Semantics/resolve-names.cpp
@@ -3124,8 +3124,15 @@
Say(*name, "Procedure '%s' not found"_err_en_US);
continue;
}
- const Symbol &specific{BypassGeneric(*symbol)};
- const Symbol &ultimate{specific.GetUltimate()};
+ // Subtlety: when *symbol is a use- or host-association, the specific
+ // procedure that is recorded in the GenericDetails below must be *symbol,
+ // not the specific procedure shadowed by a generic, because that specific
+ // procedure may be a symbol from another module and its name unavailable to
+ // emit to a module file.
+ const Symbol &bypassed{BypassGeneric(*symbol)};
+ const Symbol &specific{
+ symbol == &symbol->GetUltimate() ? bypassed : *symbol};
+ const Symbol &ultimate{bypassed.GetUltimate()};
if (!ultimate.has<SubprogramDetails>() &&
!ultimate.has<SubprogramNameDetails>()) {
Say(*name, "'%s' is not a subprogram"_err_en_US);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132686.455746.patch
Type: text/x-patch
Size: 1854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220825/129e3043/attachment.bin>
More information about the flang-commits
mailing list