Skip to content

Commit 6f30010

Browse files
committed
[flang] Fix bug with IMPORT of USE of USE
When a module contained an import of a use-association of a use-association, we weren't recognizing that the symbols was needed. The fix is the follow all of the use-associations using `GetUltimate()`. Differential Revision: https://reviews.llvm.org/D79737
1 parent e0c291a commit 6f30010

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

flang/lib/Semantics/mod-file.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ void SubprogramSymbolCollector::Collect() {
833833
for (const auto &pair : scope_) {
834834
const Symbol &symbol{*pair.second};
835835
if (const auto *useDetails{symbol.detailsIf<UseDetails>()}) {
836-
if (useSet_.count(useDetails->symbol()) > 0) {
836+
if (useSet_.count(useDetails->symbol().GetUltimate()) > 0) {
837837
need_.push_back(symbol);
838838
}
839839
}

flang/test/Semantics/modfile36.f90

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
! RUN: %S/test_modfile.sh %s %t %f18
2+
3+
! Check modfile that contains import of use-assocation of another use-association.
4+
5+
module m1
6+
interface
7+
subroutine s(x)
8+
use, intrinsic :: iso_c_binding, only: c_ptr
9+
type(c_ptr) :: x
10+
end subroutine
11+
end interface
12+
end module
13+
!Expect: m1.mod
14+
!module m1
15+
! interface
16+
! subroutine s(x)
17+
! use iso_c_binding, only: c_ptr
18+
! type(c_ptr) :: x
19+
! end
20+
! end interface
21+
!end
22+
23+
module m2
24+
use, intrinsic :: iso_c_binding, only: c_ptr
25+
interface
26+
subroutine s(x)
27+
import :: c_ptr
28+
type(c_ptr) :: x
29+
end subroutine
30+
end interface
31+
end module
32+
!Expect: m2.mod
33+
!module m2
34+
! use iso_c_binding,only:c_ptr
35+
! interface
36+
! subroutine s(x)
37+
! import::c_ptr
38+
! type(c_ptr)::x
39+
! end
40+
! end interface
41+
!end

0 commit comments

Comments
 (0)