aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-09-17 00:11:27 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-09-17 00:11:27 +0000
commit5cb047d108528cf8d0205dc4cdddf65963c9985a (patch)
treec6dc043d52112964dd9db2cb59534ee92901652a /gcc/go
parent31aeabd3c51f798a7a3cbfab4bacbce983415ad8 (diff)
downloadgcc-5cb047d108528cf8d0205dc4cdddf65963c9985a.zip
gcc-5cb047d108528cf8d0205dc4cdddf65963c9985a.tar.gz
gcc-5cb047d108528cf8d0205dc4cdddf65963c9985a.tar.bz2
Improve errors for invalid use of [...]type.
From-SVN: r178921
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/expressions.cc2
-rw-r--r--gcc/go/gofrontend/parse.cc17
2 files changed, 16 insertions, 3 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc
index 32f0612..70f5f7c 100644
--- a/gcc/go/gofrontend/expressions.cc
+++ b/gcc/go/gofrontend/expressions.cc
@@ -11789,7 +11789,7 @@ Array_construction_expression::do_check_types(Gogo*)
}
Expression* length = at->length();
- if (length != NULL)
+ if (length != NULL && !length->is_error_expression())
{
mpz_t val;
mpz_init(val);
diff --git a/gcc/go/gofrontend/parse.cc b/gcc/go/gofrontend/parse.cc
index 059d964..b18c989 100644
--- a/gcc/go/gofrontend/parse.cc
+++ b/gcc/go/gofrontend/parse.cc
@@ -2761,8 +2761,21 @@ Parse::primary_expr(bool may_be_sink, bool may_be_composite_lit,
else
this->advance_token();
if (expr->is_error_expression())
- return expr;
- ret = Expression::make_cast(ret->type(), expr, loc);
+ ret = expr;
+ else
+ {
+ Type* t = ret->type();
+ if (t->classification() == Type::TYPE_ARRAY
+ && t->array_type()->length() != NULL
+ && t->array_type()->length()->is_nil_expression())
+ {
+ error_at(ret->location(),
+ "invalid use of %<...%> in type conversion");
+ ret = Expression::make_error(loc);
+ }
+ else
+ ret = Expression::make_cast(t, expr, loc);
+ }
}
}