Skip to content

Commit

Permalink
[flang] Fix crash under -fdebug-dump-all (llvm#66224)
Browse files Browse the repository at this point in the history
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.)
  • Loading branch information
klausler authored Sep 13, 2023
1 parent 102715a commit d5cc372
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 5 additions & 2 deletions flang/lib/Semantics/runtime-type-info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,11 @@ static SomeExpr StructureExpr(evaluate::StructureConstructor &&x) {

static int GetIntegerKind(const Symbol &symbol) {
auto dyType{evaluate::DynamicType::From(symbol)};
CHECK(dyType && dyType->category() == TypeCategory::Integer);
return dyType->kind();
CHECK((dyType && dyType->category() == TypeCategory::Integer) ||
symbol.owner().context().HasError(symbol));
return dyType && dyType->category() == TypeCategory::Integer
? dyType->kind()
: symbol.owner().context().GetDefaultKind(TypeCategory::Integer);
}

// Save a rank-1 array constant of some numeric type as an
Expand Down
6 changes: 4 additions & 2 deletions flang/test/Driver/dump-all-bad.f90
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
! CHECK: Flang: symbols dump

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

0 comments on commit d5cc372

Please sign in to comment.