[flang] Prevent segfault in DynamicType::IsTkCompatibleWith

Make sure `derived_` is not null before dereferencing it.

This might only happen when there is a previous error. I saw it
compiling a test program where a USEd module was not found.

Original-commit: flang-compiler/f18@2db516556b
Reviewed-on: https://github.com/flang-compiler/f18/pull/550
This commit is contained in:
Tim Keith 2019-07-03 15:47:37 -07:00
parent 8d8a867b83
commit 0386490751

View file

@ -171,7 +171,8 @@ bool DynamicType::IsTkCompatibleWith(const DynamicType &that) const {
return true;
} else if (that.IsUnlimitedPolymorphic()) {
return false;
} else if (!IsKindCompatible(*derived_, *that.derived_)) {
} else if (!derived_ || !that.derived_ ||
!IsKindCompatible(*derived_, *that.derived_)) {
return false; // kind params don't match
} else if (!IsPolymorphic()) {
return derived_->typeSymbol() == that.derived_->typeSymbol();