From d3f5d405beba05b0ca52154d15dc338586df8e9d Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 26 Jun 2013 22:58:03 +0000 Subject: 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. git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@200440 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/go/gofrontend/parse.cc | 3 +++ 1 file changed, 3 insertions(+) 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) -- cgit v1.2.3