From patchwork Sat Mar 26 06:06:40 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 88453 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 64322B6F80 for ; Sat, 26 Mar 2011 17:06:55 +1100 (EST) Received: (qmail 14285 invoked by alias); 26 Mar 2011 06:06:52 -0000 Received: (qmail 14273 invoked by uid 22791); 26 Mar 2011 06:06:51 -0000 X-SWARE-Spam-Status: No, hits=-2.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, TW_CC, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 26 Mar 2011 06:06:46 +0000 Received: from kpbe18.cbf.corp.google.com (kpbe18.cbf.corp.google.com [172.25.105.82]) by smtp-out.google.com with ESMTP id p2Q66jkN000605 for ; Fri, 25 Mar 2011 23:06:45 -0700 Received: from pwi15 (pwi15.prod.google.com [10.241.219.15]) by kpbe18.cbf.corp.google.com with ESMTP id p2Q66hVL031350 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=NOT) for ; Fri, 25 Mar 2011 23:06:44 -0700 Received: by pwi15 with SMTP id 15so350170pwi.5 for ; Fri, 25 Mar 2011 23:06:43 -0700 (PDT) Received: by 10.142.156.10 with SMTP id d10mr1226281wfe.231.1301119603730; Fri, 25 Mar 2011 23:06:43 -0700 (PDT) Received: from coign.google.com ([216.239.45.130]) by mx.google.com with ESMTPS id 25sm2335108wfb.22.2011.03.25.23.06.42 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 25 Mar 2011 23:06:43 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: check for ... with builtin functions Date: Fri, 25 Mar 2011 23:06:40 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org The Go builtin functions other than append don't handle using ... to pass a varargs argument. This patch to the gccgo frontend checks for that. It also gives a better error message for an attempt to use ... with a type conversion. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r e304fc5e4c8c go/expressions.cc --- a/go/expressions.cc Fri Mar 25 22:44:29 2011 -0700 +++ b/go/expressions.cc Fri Mar 25 23:02:05 2011 -0700 @@ -6672,6 +6672,12 @@ 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(); diff -r e304fc5e4c8c go/parse.cc --- a/go/parse.cc Fri Mar 25 22:44:29 2011 -0700 +++ b/go/parse.cc Fri Mar 25 23:02:05 2011 -0700 @@ -2705,6 +2705,12 @@ 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