diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-06-26 22:58:03 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2013-06-26 22:58:03 +0000 |
commit | 33e84ed46b1dd6330abdfe8bcec9444a1f5d2397 (patch) | |
tree | 87581ef83e545999f52828c236d008b1e5d4a340 /gcc/go | |
parent | a9826e56fac840619ca8db20926cf48a25057774 (diff) | |
download | gcc-33e84ed46b1dd6330abdfe8bcec9444a1f5d2397.zip gcc-33e84ed46b1dd6330abdfe8bcec9444a1f5d2397.tar.gz gcc-33e84ed46b1dd6330abdfe8bcec9444a1f5d2397.tar.bz2 |
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
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gofrontend/parse.cc | 3 |
1 files changed, 3 insertions, 0 deletions
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) |