From patchwork Thu Feb 2 06:24:10 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 139087 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 5A670104785 for ; Thu, 2 Feb 2012 17:24:37 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1328768679; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:To:Subject:Date:Message-ID:User-Agent: MIME-Version:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=8HX/krqPXCHTBZpbQoXs8jEwRYQ=; b=Jd89NIiOv4bAh+L QQAl2rNp1HL00fPY9VaGafjyR8TNJeVT3h1gyhpGi2Rnwhr0gOFOx2jHP2BV0sr8 X/Phq6U0GzXGH53AySFIZb06gFStnY4SWgfYrs/4FsZbJZbLrYOaao9k+/B1NbE+ TMAMdDXQPJx2sY5ELaVhUiPReCZI= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=i5kF6I6ZqqQIPNydKr4nBDeQ7xHXX6rQYkbTKwj3SOSUytuQb/Rc++TV3afHgF IdGJDQh2t+Ar5lHjfKuTxhW/f/gaFga0qvawIfBqMqHHr4RSyTZk9sweu6A9LVsk fdggpTXnhK1eh7jNjQvsdKV+HzmnOKcsqPpGVpyYIbuQ8=; Received: (qmail 15323 invoked by alias); 2 Feb 2012 06:24:32 -0000 Received: (qmail 15314 invoked by uid 22791); 2 Feb 2012 06:24:29 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-pz0-f47.google.com (HELO mail-pz0-f47.google.com) (209.85.210.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 02 Feb 2012 06:24:16 +0000 Received: by daln34 with SMTP id n34so380107dal.20 for ; Wed, 01 Feb 2012 22:24:15 -0800 (PST) Received: by 10.68.73.106 with SMTP id k10mr5164296pbv.35.1328163855446; Wed, 01 Feb 2012 22:24:15 -0800 (PST) Received: by 10.68.73.106 with SMTP id k10mr5164273pbv.35.1328163855333; Wed, 01 Feb 2012 22:24:15 -0800 (PST) Received: from coign.google.com ([216.239.45.130]) by mx.google.com with ESMTPS id t10sm3521007pbb.18.2012.02.01.22.24.13 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 01 Feb 2012 22:24:14 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Fix method expression parameter references Date: Wed, 01 Feb 2012 22:24:10 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 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 frontend had a couple of bugs when using method expressions with parameters. It crashed if the parameters had no names. And it did the wrong thing if the types were imported. This patch fixes both problems. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 0192d111870c go/expressions.cc --- a/go/expressions.cc Wed Feb 01 13:27:58 2012 -0800 +++ b/go/expressions.cc Wed Feb 01 22:10:52 2012 -0800 @@ -11711,10 +11711,21 @@ const Typed_identifier_list* method_parameters = method_type->parameters(); if (method_parameters != NULL) { + int i = 0; for (Typed_identifier_list::const_iterator p = method_parameters->begin(); p != method_parameters->end(); - ++p) - parameters->push_back(*p); + ++p, ++i) + { + if (!p->name().empty() && p->name() != Import::import_marker) + parameters->push_back(*p); + else + { + char buf[20]; + snprintf(buf, sizeof buf, "$param%d", i); + parameters->push_back(Typed_identifier(buf, p->type(), + p->location())); + } + } } const Typed_identifier_list* method_results = method_type->results(); @@ -11774,14 +11785,14 @@ } Expression_list* args; - if (method_parameters == NULL) + if (parameters->size() <= 1) args = NULL; else { args = new Expression_list(); - for (Typed_identifier_list::const_iterator p = method_parameters->begin(); - p != method_parameters->end(); - ++p) + Typed_identifier_list::const_iterator p = parameters->begin(); + ++p; + for (; p != parameters->end(); ++p) { vno = gogo->lookup(p->name(), NULL); go_assert(vno != NULL);