Check for invalid uses of ... in builtin function calls.
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 26 Mar 2011 06:06:36 +0000 (06:06 +0000)
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>
Sat, 26 Mar 2011 06:06:36 +0000 (06:06 +0000)
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171544 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 19ac03e..e3a3ab5 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 18310cc..76dd9d0 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