compiler: Prohibit use of ellipsis operator on multi-valued calls.
authorIan Lance Taylor <ian@gcc.gnu.org>
Thu, 22 Jan 2015 04:09:04 +0000 (04:09 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 22 Jan 2015 04:09:04 +0000 (04:09 +0000)
Fixes golang/go#9525.

From-SVN: r219984

gcc/go/gofrontend/expressions.cc

index ee8af849f50892c29884d8bac707f9360e0817b0..a8bed0b66e1e74eeb65d01c17034bb81e85d108f 100644 (file)
@@ -8580,6 +8580,17 @@ Call_expression::do_lower(Gogo* gogo, Named_object* function,
        {
          Call_expression* call = this->args_->front()->call_expression();
          call->set_is_multi_value_arg();
+         if (this->is_varargs_)
+           {
+             // It is not clear which result of a multiple result call
+             // the ellipsis operator should be applied to.  If we unpack the
+             // the call into its individual results here, the ellipsis will be
+             // applied to the last result.
+             error_at(call->location(),
+                      _("multiple-value argument in single-value context"));
+             return Expression::make_error(call->location());
+           }
+
          Expression_list* args = new Expression_list;
          for (size_t i = 0; i < rc; ++i)
            args->push_back(Expression::make_call_result(call, i));