diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-03-13 20:48:15 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2015-03-13 20:48:15 +0000 |
commit | 6a686e011286ef7f9bf54e46e1b585229b603d37 (patch) | |
tree | f58d30493a0c45f5d5a8e789aff8701ffa5f6ca8 | |
parent | e2db44f2aee6dd4969b1f88d0af5ea7d7ec92a93 (diff) |
compiler: Permit label on fallthrough statement.
Test case: https://go-review.googlesource.com/7523 .
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@221428 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/go/gofrontend/parse.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index 496ab41b6e3..970e6bdd14a 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -3735,6 +3735,17 @@ Parse::labeled_stmt(const std::string& label_name, Location location) if (!this->statement_may_start_here()) { + if (this->peek_token()->is_keyword(KEYWORD_FALLTHROUGH)) + { + // We don't treat the fallthrough keyword as a statement, + // because it can't appear most places where a statement is + // permitted, but it may have a label. We introduce a + // semicolon because the caller expects to see a statement. + this->unget_token(Token::make_operator_token(OPERATOR_SEMICOLON, + location)); + return; + } + // Mark the label as used to avoid a useless error about an // unused label. if (label != NULL) |