Skip to content

Commit f5ddb10

Browse files
authored
[flang] Fix crash in module file generation (#123859)
An assertion in module file generation didn't allow for a case that has arisen in a test; remove it, extend commentary, and add a regression test. Fixes #123534.
1 parent 3ac0078 commit f5ddb10

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

flang/lib/Semantics/mod-file.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,8 +1799,8 @@ bool SubprogramSymbolCollector::NeedImport(
17991799
return found->has<UseDetails>() && found->owner() != scope_;
18001800
} else {
18011801
// "found" can be null in the case of a use-associated derived type's
1802-
// parent type
1803-
CHECK(symbol.has<DerivedTypeDetails>());
1802+
// parent type, and also in the case of an object (like a dummy argument)
1803+
// used to define a length or bound of a nested interface.
18041804
return false;
18051805
}
18061806
}

flang/test/Semantics/bug123534.f90

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
! RUN: %python %S/test_modfile.py %s %flang_fc1
2+
! Simplified regression test for crashreported in
3+
! https://github.com/llvm/llvm-project/issues/123534.
4+
module m
5+
interface
6+
! f1 returns a pointer to a procedure whose result characteristics
7+
! depend on the value of a dummy argument.
8+
function f1()
9+
interface
10+
function f2(n)
11+
integer, intent(in) :: n
12+
character(n), pointer :: f2
13+
end
14+
end interface
15+
procedure (f2), pointer :: f1
16+
end
17+
end interface
18+
end
19+
20+
!Expect: m.mod
21+
!module m
22+
!interface
23+
!function f1()
24+
!interface
25+
!function f2(n)
26+
!integer(4),intent(in)::n
27+
!character(n,1),pointer::f2
28+
!end
29+
!end interface
30+
!procedure(f2),pointer::f1
31+
!end
32+
!end interface
33+
!end

0 commit comments

Comments
 (0)