From 7a66b4fea40bc5a9f20f86beed9abc64c2adcee4 Mon Sep 17 00:00:00 2001 From: Vern Paxson Date: Thu, 23 Dec 2021 11:37:45 -0800 Subject: [PATCH] fix: ZAM could misinterpret a "type" switch that starts with a "default" --- src/script_opt/ZAM/Stmt.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/script_opt/ZAM/Stmt.cc b/src/script_opt/ZAM/Stmt.cc index f6af240c95..a9c5637310 100644 --- a/src/script_opt/ZAM/Stmt.cc +++ b/src/script_opt/ZAM/Stmt.cc @@ -410,12 +410,10 @@ const ZAMStmt ZAMCompiler::CompileSwitch(const SwitchStmt* sw) // Need to track a new set of contexts for "break" statements. PushBreaks(); - auto& cases = *sw->Cases(); - - if ( cases.length() > 0 && cases[0]->TypeCases() ) - return TypeSwitch(sw, n, c); - else + if ( sw->TypeMap()->empty() ) return ValueSwitch(sw, n, c); + else + return TypeSwitch(sw, n, c); } const ZAMStmt ZAMCompiler::ValueSwitch(const SwitchStmt* sw, const NameExpr* v, const ConstExpr* c)