[flang] Fix crash in name resolution
In an error recovery situation, the name resolution code for a SELECT TYPE statement must check the presence of an optional expression before calling GetType() upon it. Differential Revision: https://reviews.llvm.org/D140153
This commit is contained in:
parent
81b35aa69f
commit
7db05ae14d
@ -6359,14 +6359,16 @@ void ConstructVisitor::Post(const parser::SelectTypeStmt &x) {
|
||||
// This isn't a name in the current scope, it is in each TypeGuardStmt
|
||||
MakePlaceholder(*name, MiscDetails::Kind::SelectTypeAssociateName);
|
||||
association.name = &*name;
|
||||
auto exprType{association.selector.expr->GetType()};
|
||||
if (ExtractCoarrayRef(association.selector.expr)) { // C1103
|
||||
Say("Selector must not be a coindexed object"_err_en_US);
|
||||
}
|
||||
if (exprType && !exprType->IsPolymorphic()) { // C1159
|
||||
Say(association.selector.source,
|
||||
"Selector '%s' in SELECT TYPE statement must be "
|
||||
"polymorphic"_err_en_US);
|
||||
if (association.selector.expr) {
|
||||
auto exprType{association.selector.expr->GetType()};
|
||||
if (exprType && !exprType->IsPolymorphic()) { // C1159
|
||||
Say(association.selector.source,
|
||||
"Selector '%s' in SELECT TYPE statement must be "
|
||||
"polymorphic"_err_en_US);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (const Symbol *
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user