Fix empty case items crash (#3851).

This commit is contained in:
Wilson Snyder
2023-01-10 07:18:12 -05:00
parent 7e4760a7e4
commit 5fce23e90d
4 changed files with 55 additions and 1 deletions
+3 -1
View File
@@ -274,7 +274,9 @@ private:
// Convert valueItem from AstCaseItem* to the expression
// Not done earlier, as we may now have a nullptr because it's just a ";" NOP branch
for (uint32_t i = 0; i < numCases; ++i) {
m_valueItem[i] = VN_AS(m_valueItem[i], CaseItem)->stmtsp();
if (AstCaseItem* const itemp = VN_AS(m_valueItem[i], CaseItem)) {
m_valueItem[i] = itemp->stmtsp();
}
}
return true; // All is fine
}