Skip to content

Commit 6a41ace

Browse files
authored
[flang] Initializers for proc pointers in module files (#170349)
Default initializers for procedure pointer components are missing from module files; add them. Fixes #170331.
1 parent 6f1e3c3 commit 6a41ace

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

flang/lib/Semantics/mod-file.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,15 @@ void ModFileWriter::PutProcEntity(llvm::raw_ostream &os, const Symbol &symbol) {
10691069
PutPassName(os, details.passName());
10701070
},
10711071
attrs);
1072+
if (symbol.owner().IsDerivedType()) {
1073+
if (const auto &init{details.init()}) {
1074+
if (const Symbol *symbol{*init}) {
1075+
os << "=>" << symbol->name();
1076+
} else {
1077+
os << "=>NULL()";
1078+
}
1079+
}
1080+
}
10721081
os << '\n';
10731082
}
10741083

flang/test/Semantics/modfile75.f90

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
! RUN: %python %S/test_modfile.py %s %flang_fc1
2+
module m
3+
type dt
4+
procedure(sub), pointer, nopass :: p1 => sub
5+
procedure(sub), pointer, nopass :: p2 => null()
6+
procedure(sub), pointer, nopass :: p3
7+
end type
8+
procedure(sub), pointer :: p4 => sub
9+
procedure(sub), pointer :: p5 => null()
10+
contains
11+
subroutine sub
12+
end
13+
end
14+
15+
!Expect: m.mod
16+
!module m
17+
!type::dt
18+
!procedure(sub),nopass,pointer::p1=>sub
19+
!procedure(sub),nopass,pointer::p2=>NULL()
20+
!procedure(sub),nopass,pointer::p3
21+
!end type
22+
!intrinsic::null
23+
!procedure(sub),pointer::p4
24+
!procedure(sub),pointer::p5
25+
!contains
26+
!subroutine sub()
27+
!end
28+
!end

0 commit comments

Comments
 (0)