fix: ZAM could misinterpret a "type" switch that starts with a "default"

This commit is contained in:
Vern Paxson 2021-12-23 11:37:45 -08:00
parent a09c5e6bde
commit 7a66b4fea4

View file

@ -410,12 +410,10 @@ const ZAMStmt ZAMCompiler::CompileSwitch(const SwitchStmt* sw)
// Need to track a new set of contexts for "break" statements. // Need to track a new set of contexts for "break" statements.
PushBreaks(); PushBreaks();
auto& cases = *sw->Cases(); if ( sw->TypeMap()->empty() )
if ( cases.length() > 0 && cases[0]->TypeCases() )
return TypeSwitch(sw, n, c);
else
return ValueSwitch(sw, n, c); return ValueSwitch(sw, n, c);
else
return TypeSwitch(sw, n, c);
} }
const ZAMStmt ZAMCompiler::ValueSwitch(const SwitchStmt* sw, const NameExpr* v, const ConstExpr* c) const ZAMStmt ZAMCompiler::ValueSwitch(const SwitchStmt* sw, const NameExpr* v, const ConstExpr* c)