From patchwork Fri Jul 1 00:53:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 102848 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 A5BD0B6F54 for ; Fri, 1 Jul 2011 10:53:23 +1000 (EST) Received: (qmail 14405 invoked by alias); 1 Jul 2011 00:53:21 -0000 Received: (qmail 14396 invoked by uid 22791); 1 Jul 2011 00:53:19 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 01 Jul 2011 00:53:01 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p610r1nA029585 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 30 Jun 2011 20:53:01 -0400 Received: from [127.0.0.1] (ovpn-113-39.phx2.redhat.com [10.3.113.39]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p610r0up027706 for ; Thu, 30 Jun 2011 20:53:01 -0400 Message-ID: <4E0D1A6C.5050904@redhat.com> Date: Thu, 30 Jun 2011 20:53:00 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/49387 (strange error with typeid) 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 Here we were winding up in get_tinfo_decl with a template type that was still incomplete because nothing else had required it to be complete. So we initially decide to treat it as a class with no bases. But then the process of creating the initializer for the type_info node causes the type to be complete, so we generate an initializer for a class with bases, which doesn't match the type we already gave it. Fixed by instantiating the type in get_tinfo_decl. Tested x86_64-pc-linux-gnu, applying to trunk. commit 9e18be69b4b6177e94597a20b43ff42f8e8f33bb Author: Jason Merrill Date: Thu Jun 30 18:52:18 2011 -0400 PR c++/49387 * rtti.c (get_pseudo_ti_index): Call complete_type. diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 0feaf07..53404b4 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -406,6 +406,8 @@ get_tinfo_decl (tree type) type = build_function_type (TREE_TYPE (type), TREE_CHAIN (TYPE_ARG_TYPES (type))); + type = complete_type (type); + /* For a class type, the variable is cached in the type node itself. */ if (CLASS_TYPE_P (type)) diff --git a/gcc/testsuite/g++.dg/rtti/template1.C b/gcc/testsuite/g++.dg/rtti/template1.C new file mode 100644 index 0000000..e2a0376 --- /dev/null +++ b/gcc/testsuite/g++.dg/rtti/template1.C @@ -0,0 +1,23 @@ +// PR c++/49387 + +#include + +struct ResourceMonitorClient { }; + +template struct ResourcePool : public ResourceMonitorClient { + virtual ~ResourcePool() { } +}; + +template struct BaseWriter { + + BaseWriter() { + typeid(ResourcePool*); + } + + virtual void run() { + ResourcePool pool; + } + +}; + +BaseWriter b;