[flang-commits] [flang] d5cc372 - [flang] Fix crash under -fdebug-dump-all (#66224)
via flang-commits
flang-commits at lists.llvm.org
Wed Sep 13 14:05:02 PDT 2023
Author: Peter Klausler
Date: 2023-09-13T14:04:58-07:00
New Revision: d5cc372332fcf573d9182991705c58aa884e159f
URL: https://github.com/llvm/llvm-project/commit/d5cc372332fcf573d9182991705c58aa884e159f
DIFF: https://github.com/llvm/llvm-project/commit/d5cc372332fcf573d9182991705c58aa884e159f.diff
LOG: [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.)
Added:
Modified:
flang/lib/Semantics/runtime-type-info.cpp
flang/test/Driver/dump-all-bad.f90
Removed:
################################################################################
diff --git a/flang/lib/Semantics/runtime-type-info.cpp b/flang/lib/Semantics/runtime-type-info.cpp
index c46b12d6b30e86e..aa470ecdc771941 100644
--- a/flang/lib/Semantics/runtime-type-info.cpp
+++ b/flang/lib/Semantics/runtime-type-info.cpp
@@ -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
diff --git a/flang/test/Driver/dump-all-bad.f90 b/flang/test/Driver/dump-all-bad.f90
index 2d6f71a526af5b5..58f0d02c497469d 100644
--- a/flang/test/Driver/dump-all-bad.f90
+++ b/flang/test/Driver/dump-all-bad.f90
@@ -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
More information about the flang-commits
mailing list