Check for invalid uses of ... in builtin function calls.
authorIan Lance Taylor <ian@gcc.gnu.org>
Sat, 26 Mar 2011 06:06:36 +0000 (06:06 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Sat, 26 Mar 2011 06:06:36 +0000 (06:06 +0000)
From-SVN: r171544

gcc/go/gofrontend/expressions.cc
gcc/go/gofrontend/parse.cc

index 19ac03e9347e93dffdf2999d7df46b1c2da6da37..e3a3ab593ee75e6da7c63378b0656ecc5cf36e74 100644 (file)
@@ -6672,6 +6672,12 @@ Find_call_expression::expression(Expression** pexpr)
 Expression*
 Builtin_call_expression::do_lower(Gogo* gogo, Named_object* function, int)
 {
+  if (this->is_varargs() && this->code_ != BUILTIN_APPEND)
+    {
+      this->report_error(_("invalid use of %<...%> with builtin function"));
+      return Expression::make_error(this->location());
+    }
+
   if (this->code_ == BUILTIN_NEW)
     {
       const Expression_list* args = this->args();
index 18310ccac299010d56e232d1614f1f0569aadfcb..76dd9d04e435d024f3abfdba36313550a5333b3d 100644 (file)
@@ -2705,6 +2705,12 @@ Parse::primary_expr(bool may_be_sink, bool may_be_composite_lit,
          this->advance_token();
          Expression* expr = this->expression(PRECEDENCE_NORMAL, false, true,
                                              NULL);
+         if (this->peek_token()->is_op(OPERATOR_ELLIPSIS))
+           {
+             error_at(this->location(),
+                      "invalid use of %<...%> in type conversion");
+             this->advance_token();
+           }
          if (!this->peek_token()->is_op(OPERATOR_RPAREN))
            error_at(this->location(), "expected %<)%>");
          else