diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-04-24 05:55:27 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-04-24 05:55:27 +0000 |
commit | 234bdd5b07ad021270b1e81e419c9bd7ce679877 (patch) | |
tree | 93b0bd4898df6c13ba34c6e43534f925692a4cdf /gcc | |
parent | 5e0cea668e8a8d44674ebbc751afbe9dcc17339c (diff) | |
download | gcc-234bdd5b07ad021270b1e81e419c9bd7ce679877.zip gcc-234bdd5b07ad021270b1e81e419c9bd7ce679877.tar.gz gcc-234bdd5b07ad021270b1e81e419c9bd7ce679877.tar.bz2 |
compiler: Error for invalid use of ... in call.
From-SVN: r186739
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 945f379..e6d1a0d 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -8641,7 +8641,14 @@ Call_expression::lower_varargs(Gogo* gogo, Named_object* function, new_args->push_back(*pa); else if (this->is_varargs_) { - this->report_error(_("too many arguments")); + if ((*pa)->type()->is_slice_type()) + this->report_error(_("too many arguments")); + else + { + error_at(this->location(), + _("invalid use of %<...%> with non-slice")); + this->set_is_error(); + } return; } else @@ -8886,6 +8893,9 @@ Call_expression::check_argument_type(int i, const Type* parameter_type, void Call_expression::do_check_types(Gogo*) { + if (this->classification() == EXPRESSION_ERROR) + return; + Function_type* fntype = this->get_function_type(); if (fntype == NULL) { @@ -8921,7 +8931,17 @@ Call_expression::do_check_types(Gogo*) } // Note that varargs was handled by the lower_varargs() method, so - // we don't have to worry about it here. + // we don't have to worry about it here unless something is wrong. + if (this->is_varargs_ && !this->varargs_are_lowered_) + { + if (!fntype->is_varargs()) + { + error_at(this->location(), + _("invalid use of %<...%> calling non-variadic function")); + this->set_is_error(); + return; + } + } const Typed_identifier_list* parameters = fntype->parameters(); if (this->args_ == NULL) |