aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-09-23 22:23:19 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-09-23 22:23:19 +0000
commitb07000d94215ee742a8c7d0a7a38b27af106c871 (patch)
treec8ae1047860b8cdc7ce0d2fdde972bf4d49f6646 /gcc
parent2d2b02c4da9e66531c8e56703273f447fb8d49a9 (diff)
downloadgcc-b07000d94215ee742a8c7d0a7a38b27af106c871.zip
gcc-b07000d94215ee742a8c7d0a7a38b27af106c871.tar.gz
gcc-b07000d94215ee742a8c7d0a7a38b27af106c871.tar.bz2
Better parsing of erroneous expression on left of :=.
Better parsing of erroneous non-type in type switch. From-SVN: r179133
Diffstat (limited to 'gcc')
-rw-r--r--gcc/go/gofrontend/parse.cc27
1 files changed, 26 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc
index d914beb..8c42fa2 100644
--- a/gcc/go/gofrontend/parse.cc
+++ b/gcc/go/gofrontend/parse.cc
@@ -3506,7 +3506,21 @@ Parse::simple_stat(bool may_be_composite_lit, bool* return_exp,
else if (return_exp != NULL)
return this->verify_not_sink(exp);
else
- this->expression_stat(this->verify_not_sink(exp));
+ {
+ exp = this->verify_not_sink(exp);
+
+ if (token->is_op(OPERATOR_COLONEQ))
+ {
+ if (!exp->is_error_expression())
+ error_at(token->location(), "non-name on left side of %<:=%>");
+ while (!token->is_op(OPERATOR_SEMICOLON)
+ && !token->is_eof())
+ token = this->advance_token();
+ return NULL;
+ }
+
+ this->expression_stat(exp);
+ }
return NULL;
}
@@ -4287,8 +4301,19 @@ Parse::type_switch_case(std::vector<Type*>* types, bool* is_default)
while (true)
{
Type* t = this->type();
+
if (!t->is_error_type())
types->push_back(t);
+ else
+ {
+ token = this->peek_token();
+ while (!token->is_op(OPERATOR_COLON)
+ && !token->is_op(OPERATOR_COMMA)
+ && !token->is_op(OPERATOR_RCURLY)
+ && !token->is_eof())
+ token = this->advance_token();
+ }
+
if (!this->peek_token()->is_op(OPERATOR_COMMA))
break;
this->advance_token();