diff --git a/tools/binpac/src/pac_expr.cc b/tools/binpac/src/pac_expr.cc index 02303bc953..2047d2269d 100644 --- a/tools/binpac/src/pac_expr.cc +++ b/tools/binpac/src/pac_expr.cc @@ -242,6 +242,11 @@ void Expr::GenCaseEval(Output *out_cc, Env *env) Type *val_type = DataType(env); ID *val_var = env->AddTempID(val_type); + // DataType(env) can return a null pointer if an enum value is not + // defined. + if ( ! val_type ) + throw Exception(this, "undefined case value"); + out_cc->println("%s %s;", val_type->DataTypeStr().c_str(), env->LValue(val_var));