Commit 6540ddba by Ian Lance Taylor

Don't crash on type switch of nil.

From-SVN: r170455
parent d6007535
......@@ -3905,10 +3905,13 @@ Type_switch_statement::do_lower(Gogo*, Block* enclosing)
{
// Doing a type switch on a non-interface type. Should we issue
// a warning for this case?
// descriptor_temp = DESCRIPTOR
Expression* lhs = Expression::make_temporary_reference(descriptor_temp,
loc);
Expression* rhs = Expression::make_type_descriptor(val_type, loc);
Expression* rhs;
if (val_type->is_nil_type())
rhs = Expression::make_nil(loc);
else
rhs = Expression::make_type_descriptor(val_type, loc);
Statement* s = Statement::make_assignment(lhs, rhs, loc);
b->add_statement(s);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment