From patchwork Thu Jun 27 20:52:14 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 255226 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id A51082C02E8 for ; Fri, 28 Jun 2013 06:52:27 +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=bOtQ6wu3cKX1l0ViUQgC7SKvv8TYRMGr3ea9uVy6dFZjzTC5L4y2g LWSWm11UMIaLlFKqKqbP/obCzABs1JbO4cuFOFqg1BdaLaFIers/7qCqhd10gliZ jS+R46DasRkIsvIGuVIz3qNrcFhzda069zJsl5h95TfCcPtndVkJ54= 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=MgZHp5VJaR8qBWYAyMtP3ncBkHw=; b=HqMVMnopXx/SRG5Rhz5u +SAQV0+LSnwTKhMluOAvzIGofqT2C0PcphX/bbJM7WD3NdFZzkVSJPoIH9l/atR6 AIY0Kxz1uFz4sZDZRb6lqkNScnyLqX8boXtEpO2k6KFCzRXnru74TrHHuAo/crbu mrtpBAzaFJO0kgVgdqfnkas= Received: (qmail 10039 invoked by alias); 27 Jun 2013 20:52:21 -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 10006 invoked by uid 89); 27 Jun 2013 20:52:18 -0000 X-Spam-SWARE-Status: No, score=-3.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS, TW_FN autolearn=ham version=3.3.1 Received: from mail-pd0-f173.google.com (HELO mail-pd0-f173.google.com) (209.85.192.173) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 27 Jun 2013 20:52:17 +0000 Received: by mail-pd0-f173.google.com with SMTP id v14so600621pde.4 for ; Thu, 27 Jun 2013 13:52:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type:x-gm-message-state; bh=CnpAkA/wq5lmH2liWHQWKAB3qwPSERhWmnJpmNFw5VM=; b=Ujgl32kuE1sPrM4sk9PuqIcnlZq7elP1Zp4z/HWETMddjbodd5Q9OyXQWClSl459zY GPdRVDD5E7pGUICaTFWU0FXAHHYDK/s916QiyluiBmkchT6zySvwEzbCMvjFcQPBjVd0 j4/eUKDZouEtPjPq5U/F2dsRUWPcBQVfpX7G2wGnxPUCq3yu0CEs1WPf2vnYDru0Qhx7 AD9hqRA1Oxx3NEj7Fb8anpjvbKXrfSyCOB0wo/iqqQzMYZGDNBM03I2uSiqOa2Yf+Dbt vFHr9ugbvaYG5bJVlxupC9OJCEdwzEiqxFpzoIJlS8sjvkF3b1ho7raB0j8j5ck00uMS bTtg== X-Received: by 10.68.202.41 with SMTP id kf9mr8045643pbc.80.1372366335470; Thu, 27 Jun 2013 13:52:15 -0700 (PDT) Received: from iant-glaptop.roam.corp.google.com.google.com ([172.19.240.251]) by mx.google.com with ESMTPSA id br1sm4668509pbb.4.2013.06.27.13.52.14 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 27 Jun 2013 13:52:14 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org Subject: Go patch committed: Fix method sets with embedded pointer types Date: Thu, 27 Jun 2013 13:52:14 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlissFQOpb+RXxRchL0jeXe07ZG7z186I+3FH3jKjYLHHhS8UgWDdhLxV/ZKO6Tbc8pgyygWZ+33Ok83r5HmkM+LaGpAVq9b7t3v0Zk2qDWt5ofCMT1av4vJeTpL1sGXruwnG2wtYBG41aTHD4h7O3eL/k7onaU29zSsqU3H+UVyXiQO6zOyqsnuMXYQSl49i2ofFWBF6mk+flVSf3NSuXHBfFOZKmnmNCxLbL89fQxVyV6TGY= X-Virus-Found: No This patch from Rémy Oudompheng fixes the handling of method sets for structs with embedded pointer fields. Any such methods can be value methods of the struct, not just pointer methods. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline and 4.8 branch. Ian diff -r bd3d5e75023b go/types.cc --- a/go/types.cc Thu Jun 27 12:19:13 2013 -0700 +++ b/go/types.cc Thu Jun 27 13:49:08 2013 -0700 @@ -9396,13 +9396,18 @@ fnt = pf->type()->deref()->named_type(); go_assert(fnt != NULL); + // Methods with pointer receivers on embedded field are + // inherited by the pointer to struct, and also by the struct + // type if the field itself is a pointer. + bool can_be_pointer = (receiver_can_be_pointer + || pf->type()->points_to() != NULL); int sublevel = level == NULL ? 1 : *level + 1; bool sub_is_method; std::string subambig1; std::string subambig2; bool subfound = Type::find_field_or_method(fnt, name, - receiver_can_be_pointer, + can_be_pointer, seen, &sublevel, &sub_is_method,