[flang-commits] [flang] 7db05ae - [flang] Fix crash in name resolution
Peter Klausler via flang-commits
flang-commits at lists.llvm.org
Sat Dec 17 17:23:59 PST 2022
Author: Peter Klausler
Date: 2022-12-17T17:23:52-08:00
New Revision: 7db05ae14d7982fbcbcd7e596de588c6cd911c38
URL: https://github.com/llvm/llvm-project/commit/7db05ae14d7982fbcbcd7e596de588c6cd911c38
DIFF: https://github.com/llvm/llvm-project/commit/7db05ae14d7982fbcbcd7e596de588c6cd911c38.diff
LOG: [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
Added:
Modified:
flang/lib/Semantics/resolve-names.cpp
Removed:
################################################################################
diff --git a/flang/lib/Semantics/resolve-names.cpp b/flang/lib/Semantics/resolve-names.cpp
index 29a7c2fe286d..fdc3b3e350cc 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 *
More information about the flang-commits
mailing list