summaryrefslogtreecommitdiff
path: root/gcc/go/gofrontend/parse.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-03-28 23:13:04 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-03-28 23:13:04 +0000
commitb9da60aea69647fd7957dc328a8431412157d3a7 (patch)
treea12563b9a820aac5161567bd37d8de35dc23ecec /gcc/go/gofrontend/parse.cc
parent0753192b5bcb617b5edf5dfe53f34b40ec58c697 (diff)
downloadgcc-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.cc13
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 %<{%>");