From: Ian Lance Taylor Date: Mon, 28 Mar 2011 23:13:04 +0000 (+0000) Subject: Better error message for invalid variable name in switch statement. X-Git-Tag: releases/gcc-4.7.0~7951 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b9da60aea69647fd7957dc328a8431412157d3a7;p=thirdparty%2Fgcc.git Better error message for invalid variable name in switch statement. From-SVN: r171639 --- diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc index c7cd1087b803..fb590195597a 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 %<{%>");