From 33e84ed46b1dd6330abdfe8bcec9444a1f5d2397 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. From-SVN: r200440 --- gcc/go/gofrontend/parse.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc/go') diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index 0a67bbe..5a9feb7 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.1