diff options
author | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-02-01 21:30:48 +0000 |
---|---|---|
committer | ian <ian@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-02-01 21:30:48 +0000 |
commit | 19fd40c35641b624421531b6d2b8c2a9cd9124b5 (patch) | |
tree | b4c4d2519a9f39f634f00083dc72e298d8f4c3e6 /gcc/go | |
parent | 3227fca2b33540ddf1f11cd5a9418e281a406ad9 (diff) | |
download | gcc-19fd40c35641b624421531b6d2b8c2a9cd9124b5.tar.gz |
compiler: Fix type checking for append.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@183816 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/go')
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 5563dde7032..25b79872787 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -7657,7 +7657,10 @@ Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function, this->set_is_error(); return this; } - this->lower_varargs(gogo, function, inserter, slice_type, 2); + Type* element_type = slice_type->array_type()->element_type(); + this->lower_varargs(gogo, function, inserter, + Type::make_array_type(element_type, NULL), + 2); } break; @@ -8624,16 +8627,20 @@ Builtin_call_expression::do_check_types(Gogo*) break; } + // The language says that the second argument must be + // assignable to a slice of the element type of the first + // argument. We already know the first argument is a slice + // type. + Array_type* at = args->front()->type()->array_type(); + Type* arg2_type = Type::make_array_type(at->element_type(), NULL); std::string reason; - if (!Type::are_assignable(args->front()->type(), args->back()->type(), - &reason)) + if (!Type::are_assignable(arg2_type, args->back()->type(), &reason)) { if (reason.empty()) - this->report_error(_("arguments 1 and 2 have different types")); + this->report_error(_("argument 2 has invalid type")); else { - error_at(this->location(), - "arguments 1 and 2 have different types (%s)", + error_at(this->location(), "argument 2 has invalid type (%s)", reason.c_str()); this->set_is_error(); } |