Skip to content

Commit d5cc372

Browse files
authored
[flang] Fix crash under -fdebug-dump-all (#66224)
The -fdebug-dump-all flag invokes runtime type information generation even for a program with fatal semantic errors. This could cause a crash on a failed CHECK(), since the type information table generator assumes a correct program. Make it more resilient for a known fatal case. (But if we hit many more of these, we should look into not generating the runtime type information tables under this flag.)
1 parent 102715a commit d5cc372

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

flang/lib/Semantics/runtime-type-info.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,11 @@ static SomeExpr StructureExpr(evaluate::StructureConstructor &&x) {
310310

311311
static int GetIntegerKind(const Symbol &symbol) {
312312
auto dyType{evaluate::DynamicType::From(symbol)};
313-
CHECK(dyType && dyType->category() == TypeCategory::Integer);
314-
return dyType->kind();
313+
CHECK((dyType && dyType->category() == TypeCategory::Integer) ||
314+
symbol.owner().context().HasError(symbol));
315+
return dyType && dyType->category() == TypeCategory::Integer
316+
? dyType->kind()
317+
: symbol.owner().context().GetDefaultKind(TypeCategory::Integer);
315318
}
316319

317320
// Save a rank-1 array constant of some numeric type as an

flang/test/Driver/dump-all-bad.f90

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
! CHECK: Flang: symbols dump
1111

1212
program bad
13-
real,pointer :: x
14-
x = null() ! Error - must be pointer assignment
13+
type dt(k)
14+
integer(kind=16) :: k
15+
integer(kind=16) :: comp
16+
end type dt
1517
end

0 commit comments

Comments
 (0)