[flang-commits] [PATCH] D132683: flang] Emit missing IMPORTs in module file interfaces
Peter Klausler via Phabricator via flang-commits
flang-commits at lists.llvm.org
Thu Aug 25 15:10:34 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdf3e5f18d0eb: [flang] Emit missing IMPORTs in module file interfaces (authored by klausler).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132683/new/
https://reviews.llvm.org/D132683
Files:
flang/lib/Semantics/mod-file.cpp
flang/test/Semantics/modfile46.f90
flang/test/Semantics/modfile49.f90
Index: flang/test/Semantics/modfile49.f90
===================================================================
--- /dev/null
+++ flang/test/Semantics/modfile49.f90
@@ -0,0 +1,41 @@
+! RUN: %python %S/test_modfile.py %s %flang_fc1
+! Ensure that symbols and types needed to declare procedures and procedure pointers
+! are properly imported into interfaces.
+module m
+ type :: t
+ end type
+ procedure(sin) :: ext
+ interface
+ subroutine subr(p1,p2)
+ import ext, t
+ procedure(ext) :: p1
+ procedure(type(t)), pointer :: p2
+ end subroutine
+ function fun() result(res)
+ import subr
+ procedure(subr), pointer :: res
+ end function
+ end interface
+end module
+
+!Expect: m.mod
+!module m
+!type::t
+!end type
+!intrinsic::sin
+!procedure(sin)::ext
+!interface
+!subroutine subr(p1,p2)
+!import::ext
+!import::t
+!procedure(ext)::p1
+!procedure(type(t)),pointer::p2
+!end
+!end interface
+!interface
+!function fun() result(res)
+!import::subr
+!procedure(subr),pointer::res
+!end
+!end interface
+!end
Index: flang/test/Semantics/modfile46.f90
===================================================================
--- flang/test/Semantics/modfile46.f90
+++ flang/test/Semantics/modfile46.f90
@@ -39,17 +39,17 @@
!contains
!function f(x)
!real(4),intent(in)::x
-!procedure(used_int),pointer::f
!abstract interface
!subroutine used_int(x,p)
!real(4),intent(out)::x
-!procedure(inner_int)::p
!interface
!subroutine inner_int(x)
!real(4),intent(out)::x
!end
!end interface
+!procedure(inner_int)::p
!end
!end interface
+!procedure(used_int),pointer::f
!end
!end
Index: flang/lib/Semantics/mod-file.cpp
===================================================================
--- flang/lib/Semantics/mod-file.cpp
+++ flang/lib/Semantics/mod-file.cpp
@@ -1185,6 +1185,12 @@
DoSymbol(*object);
}
},
+ [this](const ProcEntityDetails &details) {
+ if (const Symbol * symbol{details.interface().symbol()}) {
+ DoSymbol(*symbol);
+ }
+ DoType(details.interface().type());
+ },
[](const auto &) {},
},
symbol.details());
@@ -1241,6 +1247,8 @@
const SourceName &name, const Symbol &symbol) {
if (!isInterface_) {
return false;
+ } else if (&symbol == scope_.symbol()) {
+ return false;
} else if (symbol.owner().Contains(scope_)) {
return true;
} else if (const Symbol * found{scope_.FindSymbol(name)}) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132683.455732.patch
Type: text/x-patch
Size: 2611 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/flang-commits/attachments/20220825/7584cdb1/attachment.bin>
More information about the flang-commits
mailing list