From patchwork Thu Sep 2 00:08:21 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 63428 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 946E0B7149 for ; Thu, 2 Sep 2010 10:09:00 +1000 (EST) Received: (qmail 18216 invoked by alias); 2 Sep 2010 00:08:47 -0000 Received: (qmail 18158 invoked by uid 22791); 2 Sep 2010 00:08:37 -0000 X-SWARE-Spam-Status: No, hits=-2.0 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) (74.125.121.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Sep 2010 00:08:32 +0000 Received: from kpbe15.cbf.corp.google.com (kpbe15.cbf.corp.google.com [172.25.105.79]) by smtp-out.google.com with ESMTP id o8208SNg025872 for ; Wed, 1 Sep 2010 17:08:29 -0700 Received: from pxi11 (pxi11.prod.google.com [10.243.27.11]) by kpbe15.cbf.corp.google.com with ESMTP id o8208RYI028589 for ; Wed, 1 Sep 2010 17:08:27 -0700 Received: by pxi11 with SMTP id 11so3441213pxi.20 for ; Wed, 01 Sep 2010 17:08:27 -0700 (PDT) Received: by 10.114.53.4 with SMTP id b4mr9624844waa.190.1283386107266; Wed, 01 Sep 2010 17:08:27 -0700 (PDT) Received: from coign.google.com ([66.109.106.2]) by mx.google.com with ESMTPS id d38sm19527066wam.20.2010.09.01.17.08.24 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 01 Sep 2010 17:08:26 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: [gccgo] Better message for use of [...] outside of array literal Date: Wed, 01 Sep 2010 17:08:21 -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 This patch to gccgo gives a better message for an erronsous use of [...] outside of an array literal. Committed to gccgo branch. Ian diff -r 68086824a127 go/parse.cc --- a/go/parse.cc Wed Sep 01 16:53:16 2010 -0700 +++ b/go/parse.cc Wed Sep 01 17:05:42 2010 -0700 @@ -375,9 +375,9 @@ this->advance_token(); else { - if (!may_use_ellipsis || !token->is_op(OPERATOR_ELLIPSIS)) + if (!token->is_op(OPERATOR_ELLIPSIS)) length = this->expression(PRECEDENCE_NORMAL, false, true, NULL); - else + else if (may_use_ellipsis) { // An ellipsis is used in composite literals to represent a // fixed array of the size of the number of elements. We @@ -386,6 +386,12 @@ length = Expression::make_nil(this->location()); this->advance_token(); } + else + { + this->error("use of %<[...]%> outside of array literal"); + length = Expression::make_error(this->location()); + this->advance_token(); + } if (!this->peek_token()->is_op(OPERATOR_RSQUARE)) { this->error("expected %<]%>"); diff -r 68086824a127 go/types.cc --- a/go/types.cc Wed Sep 01 16:53:16 2010 -0700 +++ b/go/types.cc Wed Sep 01 17:05:42 2010 -0700 @@ -3418,7 +3418,8 @@ } else { - error_at(this->length_->location(), "array bound is not numeric"); + if (!t->is_error_type()) + error_at(this->length_->location(), "array bound is not numeric"); return false; }