From: Ian Lance Taylor Date: Wed, 26 Jun 2013 22:58:03 +0000 (+0000) Subject: compiler: disallow fallthrough in last case of switch. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=33e84ed46b1dd6330abdfe8bcec9444a1f5d2397;p=gcc.git 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 --- diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index 0a67bbe4060..5a9feb7280b 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -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)