aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2013-06-26 22:58:03 +0000
committerIan Lance Taylor <iant@google.com>2013-06-26 22:58:03 +0000
commitd3f5d405beba05b0ca52154d15dc338586df8e9d (patch)
tree87581ef83e545999f52828c236d008b1e5d4a340
parente0c96ea0c6a868e20a09f8eb99252e83e06a9658 (diff)
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
-rw-r--r--gcc/go/gofrontend/parse.cc3
1 files changed, 3 insertions, 0 deletions
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)