From patchwork Thu Nov 11 00:45:39 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: 70739 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 431F9B7117 for ; Thu, 11 Nov 2010 11:46:07 +1100 (EST) Received: (qmail 5168 invoked by alias); 11 Nov 2010 00:46:05 -0000 Received: (qmail 5154 invoked by uid 22791); 11 Nov 2010 00:46:03 -0000 X-SWARE-Spam-Status: No, hits=-4.6 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, 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, 11 Nov 2010 00:45:57 +0000 Received: from kpbe12.cbf.corp.google.com (kpbe12.cbf.corp.google.com [172.25.105.76]) by smtp-out.google.com with ESMTP id oAB0js0g005471 for ; Wed, 10 Nov 2010 16:45:54 -0800 Received: from pvh11 (pvh11.prod.google.com [10.241.210.203]) by kpbe12.cbf.corp.google.com with ESMTP id oAB0jqFe031614 for ; Wed, 10 Nov 2010 16:45:53 -0800 Received: by pvh11 with SMTP id 11so373653pvh.18 for ; Wed, 10 Nov 2010 16:45:52 -0800 (PST) Received: by 10.142.139.8 with SMTP id m8mr7737wfd.208.1289436352747; Wed, 10 Nov 2010 16:45:52 -0800 (PST) Received: from coign.google.com ([67.218.104.238]) by mx.google.com with ESMTPS id w14sm1552600wfd.18.2010.11.10.16.45.50 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 10 Nov 2010 16:45:51 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: [gccgo] Use stub methods in type descriptors Date: Wed, 10 Nov 2010 16:45:39 -0800 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 For embedded methods the Go frontend often needs to generate a stub method, a small method which is similar to a C++ multiple inheritance thunk. The compiler was incorrectly failing to put these stub methods in the type descriptor. This patch fixes that. Committed to gccgo branch. Ian diff -r 2809673826c1 go/types.cc --- a/go/types.cc Wed Nov 10 15:36:06 2010 -0800 +++ b/go/types.cc Wed Nov 10 16:42:42 2010 -0800 @@ -1369,7 +1369,15 @@ vals->push_back(Expression::make_unary(OPERATOR_AND, s, bloc)); } - Function_type* mtype = m->type(); + Named_object* no = (m->needs_stub_method() + ? m->stub_object() + : m->named_object()); + + Function_type* mtype; + if (no->is_function()) + mtype = no->func_value()->type(); + else + mtype = no->func_declaration_value()->type(); gcc_assert(mtype->is_method()); Type* nonmethod_type = mtype->copy_without_receiver(); @@ -1383,8 +1391,7 @@ ++p; gcc_assert(p->field_name() == "tfn"); - vals->push_back(Expression::make_func_reference(m->named_object(), NULL, - bloc)); + vals->push_back(Expression::make_func_reference(no, NULL, bloc)); ++p; gcc_assert(p == fields->end()); diff -r 2809673826c1 go/types.h --- a/go/types.h Wed Nov 10 15:36:06 2010 -0800 +++ b/go/types.h Wed Nov 10 16:42:42 2010 -0800 @@ -161,6 +161,14 @@ Named_object* named_object() const; + // Get the stub object. + Named_object* + stub_object() const + { + gcc_assert(this->stub_ != NULL); + return this->stub_; + } + // Set the stub object. void set_stub_object(Named_object* no)