From: Peter Klausler Date: Sat, 17 Dec 2022 23:25:45 +0000 (-0800) Subject: [flang] Fix crash in name resolution X-Git-Tag: upstream/17.0.6~23365 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7db05ae14d7982fbcbcd7e596de588c6cd911c38;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp index 29a7c2f..fdc3b3e 100644 --- a/flang/lib/Semantics/resolve-names.cpp +++ b/flang/lib/Semantics/resolve-names.cpp @@ -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 *