From patchwork Wed Aug 27 04:12:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 383299 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 16FAF140086 for ; Wed, 27 Aug 2014 14:13:10 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=XFHyRoruuyxOP/OwlXxDiA6pDVKnHtJMFGiTjxNKU/ve+oc76CRLG LIRWqlRQ4hJChvOdLlifCZaFs069wsNyBp4WybU+u7QmxOJw/3MDOZlWunPhzgKQ tDhAawByeObTDZM0EuK7WqiVs5V1H1vyZ9w5WmpUITlJmNVXiYNj64= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=wZFAHPHuQ75giYrRyVDy5eJb420=; b=u9319sI7OTLi3fnHTAKm aJU+6NA2z+mFc/wWC8/3m3AzH0CRgQkufZu3A60ZIxECVkGsu8pAisSgjCie96nJ InsLx3H3ofTESEzyRGuPx5QKzMgS+8N4csXforGX2PUsbY7IJ0ZKeXI7QZk7VQKl vaLqKPi3QSnOuGt7HREpUBk= Received: (qmail 18546 invoked by alias); 27 Aug 2014 04:13:01 -0000 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 Received: (qmail 18407 invoked by uid 89); 27 Aug 2014 04:12:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, SPF_PASS, T_TVD_MIME_NO_HEADERS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f169.google.com Received: from mail-yk0-f169.google.com (HELO mail-yk0-f169.google.com) (209.85.160.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 27 Aug 2014 04:12:57 +0000 Received: by mail-yk0-f169.google.com with SMTP id 131so12404123ykp.14 for ; Tue, 26 Aug 2014 21:12:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:user-agent :mime-version:content-type; bh=kM7LW6R2SQXgy/VqYJhnc+PpZh0Ru6vp//pQw2oVgyw=; b=lrZexaCTACnSbdc5pHwv4h7CeAKs2+m6FrWcAc4aU5LMXbFufzdk/0u/htZEcuEIGx 9ZfRmCutbwNXu8TFtl09zXHe1r0/24BONFnhFTvkfMSTYfLKAWoUu/BOUBJXOPe+R30x YjYEmD4yAqoncq11FK2g8YF9a2FGP5bPTYvpM+8LBdXj505pyeTOWq6MQTrZr1x8lnuv rCJoRbClDzB5m2Gd1qHc3VyMBcBq8mg9KjFa+TydT1bub7O2J3VTydLvaWgqag03IMUo 7X4gy8sSx4N6xTBIUva726cgzdSsP14hIuoc2EAnpgSYyy5MJPoA0fvEAhIFgo9L8BOC +Awg== X-Gm-Message-State: ALoCoQnZzFC3fGGvZE4F7IqyH8gPdbyBrbhj5a1SkRZzM4hkvVq8Qp1MPQW2zsFUMWBBfk3G19Ya X-Received: by 10.236.27.105 with SMTP id d69mr50238263yha.72.1409112775651; Tue, 26 Aug 2014 21:12:55 -0700 (PDT) Received: from iant-glaptop.roam.corp.google.com.google.com ([172.26.41.96]) by mx.google.com with ESMTPSA id h65sm3058100yhd.45.2014.08.26.21.12.54 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 26 Aug 2014 21:12:54 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: Go patch committed: Disallow call of *T method using **T variable Date: Tue, 26 Aug 2014 21:12:53 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes This patch by Chris Manghane fixes the Go frontend to not permit calling a pointer method on *T with a variable of **T. Previously it was incorrectly dereferencing the **T to get a *T and using that to call the method. Fixing this required tweaking one test case. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. This fixes issue 8583 in the Go project. Ian Index: gcc/go/gofrontend/types.cc =================================================================== --- gcc/go/gofrontend/types.cc (revision 213928) +++ gcc/go/gofrontend/types.cc (working copy) @@ -9453,10 +9453,11 @@ Type::bind_field_or_method(Gogo* gogo, c else go_unreachable(); go_assert(m != NULL); - if (dereferenced && m->is_value_method()) + if (dereferenced) { error_at(location, - "calling value method requires explicit dereference"); + "calling method %qs requires explicit dereference", + Gogo::message_name(name).c_str()); return Expression::make_error(location); } if (!m->is_value_method() && expr->type()->points_to() == NULL) Index: gcc/testsuite/go.test/test/fixedbugs/bug371.go =================================================================== --- gcc/testsuite/go.test/test/fixedbugs/bug371.go (revision 213928) +++ gcc/testsuite/go.test/test/fixedbugs/bug371.go (working copy) @@ -8,10 +8,10 @@ package main -type T struct {} +type T struct{} func (t *T) pm() {} -func (t T) m() {} +func (t T) m() {} func main() { p := &T{} @@ -20,5 +20,5 @@ func main() { q := &p q.m() // ERROR "requires explicit dereference" - q.pm() + q.pm() // ERROR "requires explicit dereference" }