Commit 33e84ed4 by Ian Lance Taylor

compiler: disallow fallthrough in last case of switch.

In spec: A "fallthrough" statement may appear as the last
statement of all but the last clause of an expression switch.

From-SVN: r200440
parent a9826e56
......@@ -4523,9 +4523,12 @@ Parse::expr_case_clause(Case_clauses* clauses, bool* saw_default)
bool is_fallthrough = false;
if (this->peek_token()->is_keyword(KEYWORD_FALLTHROUGH))
{
Location fallthrough_loc = this->location();
is_fallthrough = true;
if (this->advance_token()->is_op(OPERATOR_SEMICOLON))
this->advance_token();
if (this->peek_token()->is_op(OPERATOR_RCURLY))
error_at(fallthrough_loc, _("cannot fallthrough final case in switch"));
}
if (is_default)
......
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