diff --git a/flang/lib/Semantics/mod-file.cpp b/flang/lib/Semantics/mod-file.cpp index 67523c468f18..d7f149467dd7 100644 --- a/flang/lib/Semantics/mod-file.cpp +++ b/flang/lib/Semantics/mod-file.cpp @@ -290,6 +290,9 @@ void ModFileWriter::PrepareRenamings(const Scope &scope) { // to their names in this scope, creating those new names when needed. auto &renamings{context_.moduleFileOutputRenamings()}; for (SymbolRef s : symbolsNeeded) { + if (s->owner().kind() == Scope::Kind::DerivedType) { + continue; // component or binding: ok + } const Scope *sMod{FindModuleContaining(s->owner())}; if (!sMod || sMod == &scope) { continue; diff --git a/flang/test/Semantics/modfile03.f90 b/flang/test/Semantics/modfile03.f90 index 39f56ca41584..eb3136f0aa8b 100644 --- a/flang/test/Semantics/modfile03.f90 +++ b/flang/test/Semantics/modfile03.f90 @@ -222,3 +222,52 @@ end !real(4)::a(1_8:int(m8a$foo(10_4),kind=8)) !end !end + +module m9a + private + public t + type t + integer n + contains + procedure f + end type + contains + pure integer function f(x, k) + class(t), intent(in) :: x + integer, intent(in) :: k + f = x%n + k + end +end +!Expect: m9a.mod +!module m9a +!type::t +!integer(4)::n +!contains +!procedure::f +!end type +!private::f +!contains +!pure function f(x,k) +!class(t),intent(in)::x +!integer(4),intent(in)::k +!integer(4)::f +!end +!end + +module m9b + use m9a + contains + subroutine s(x, y) + class(t), intent(in) :: x + real y(x%f(x%n)) + end +end +!Expect: m9b.mod +!module m9b +!use m9a,only:t +!contains +!subroutine s(x,y) +!class(t),intent(in)::x +!real(4)::y(1_8:int(x%f(x%n),kind=8)) +!end +!end