diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-03-28 23:13:04 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2011-03-28 23:13:04 +0000 |
commit | b9da60aea69647fd7957dc328a8431412157d3a7 (patch) | |
tree | a12563b9a820aac5161567bd37d8de35dc23ecec /gcc/go/gofrontend/parse.cc | |
parent | 0753192b5bcb617b5edf5dfe53f34b40ec58c697 (diff) | |
download | gcc-b9da60aea69647fd7957dc328a8431412157d3a7.tar.gz |
Better error message for invalid variable name in switch statement.
From-SVN: r171639
Diffstat (limited to 'gcc/go/gofrontend/parse.cc')
-rw-r--r-- | gcc/go/gofrontend/parse.cc | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index c7cd1087b80..fb590195597 100644 --- a/gcc/go/gofrontend/parse.cc +++ b/gcc/go/gofrontend/parse.cc @@ -3919,6 +3919,19 @@ Parse::switch_stat(Label* label) if (this->peek_token()->is_op(OPERATOR_SEMICOLON) && this->advance_token()->is_op(OPERATOR_LCURLY)) error_at(token_loc, "unexpected semicolon or newline before %<{%>"); + else if (this->peek_token()->is_op(OPERATOR_COLONEQ)) + { + error_at(token_loc, "invalid variable name"); + this->advance_token(); + this->expression(PRECEDENCE_NORMAL, false, false, + &type_switch.found); + if (this->peek_token()->is_op(OPERATOR_SEMICOLON)) + this->advance_token(); + if (!this->peek_token()->is_op(OPERATOR_LCURLY)) + return; + if (type_switch.found) + type_switch.expr = Expression::make_error(location); + } else { error_at(this->location(), "expected %<{%>"); |