Commit b9da60ae by Ian Lance Taylor

Better error message for invalid variable name in switch statement.

From-SVN: r171639
parent 0753192b
......@@ -3919,6 +3919,19 @@ Parse::switch_stat(Label* label)
if (this->peek_token()->is_op(OPERATOR_SEMICOLON)
&& this->advance_token()->is_op(OPERATOR_LCURLY))
error_at(token_loc, "unexpected semicolon or newline before %<{%>");
else if (this->peek_token()->is_op(OPERATOR_COLONEQ))
{
error_at(token_loc, "invalid variable name");
this->advance_token();
this->expression(PRECEDENCE_NORMAL, false, false,
&type_switch.found);
if (this->peek_token()->is_op(OPERATOR_SEMICOLON))
this->advance_token();
if (!this->peek_token()->is_op(OPERATOR_LCURLY))
return;
if (type_switch.found)
type_switch.expr = Expression::make_error(location);
}
else
{
error_at(this->location(), "expected %<{%>");
......
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