From patchwork Wed Feb 8 09:27:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 140079 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 01E5DB6EE7 for ; Wed, 8 Feb 2012 20:27:47 +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=1329298071; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=IfDqw5D 2neEZoEUPz+sQIBiZOjQ=; b=KyuzuHJJM2UoasCACCjJSWoPIedyLpxK22x8hKd zAE//D4XEh4OTnsHdpAuMjO2C3Z7tWyElVE7YJJ4zrLPBn38jQvaHQR7BPYYKLlQ 4Jjx+EOFemh9B8uzOKfucmkrxXXdKpNXA1H6YleJHokVeROXHRXEWHyNuX8OWjIA iLK8= 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:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=L20676yOs7jLhcRzK4gcZetV9SGDIQOT2Mvkyj+UEjvMxcp8bjvabJ9SibkbWW oVpPafTu3SYgBYJ18UFsgQQoJjatNglESGpgTEukYwvAPkR1AbOpOoFTQn3e11xD /yH3ihSKb6fu2GAz/mZqV6IS1mYdIX70lnxfViMXGoGAI=; Received: (qmail 23570 invoked by alias); 8 Feb 2012 09:27:41 -0000 Received: (qmail 23556 invoked by uid 22791); 8 Feb 2012 09:27:40 -0000 X-SWARE-Spam-Status: No, hits=-6.6 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; Wed, 08 Feb 2012 09:27:17 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q189RH2B020353 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 8 Feb 2012 04:27:17 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q189RHHe014641 for ; Wed, 8 Feb 2012 04:27:17 -0500 Received: from [0.0.0.0] (ovpn-113-40.phx2.redhat.com [10.3.113.40]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id q189RFRq016007 for ; Wed, 8 Feb 2012 04:27:16 -0500 Message-ID: <4F323FF3.2070002@redhat.com> Date: Tue, 07 Feb 2012 23:27:15 -1000 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0) Gecko/20120131 Thunderbird/10.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/52035 (LTO ICE with typedef in class template) 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 issue here is that when we go to instantiate QVector::insert, we use the out-of-class definition which uses the typedef rather than the in-class declaration which uses plain int. But we haven't instantiated the typedef yet, so when we look for the instantiation we get nothing and end up just returning the template version of the typedef. So we end up referring to uninstantiated trees, which leads to an abort in the LTO streamer. Fixed by stripping the typedef if we don't find an instantiation. Tested x86_64-pc-linux-gnu, applying to trunk. commit d8cfecd974c2515465f9be396d52a128db88f9e9 Author: Jason Merrill Date: Mon Feb 6 11:29:37 2012 -1000 PR c++/52035 * pt.c (tsubst): Strip uninstantiated typedef. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 4c93b31..a0b2a0b 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11178,7 +11178,9 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) complain | tf_ignore_bad_quals); return r; } - /* Else we must be instantiating the typedef, so fall through. */ + else + /* We don't have an instantiation yet, so drop the typedef. */ + t = DECL_ORIGINAL_TYPE (decl); } if (type diff --git a/gcc/testsuite/g++.dg/lto/README b/gcc/testsuite/g++.dg/lto/README index 5fa3123..1a13dd9 100644 --- a/gcc/testsuite/g++.dg/lto/README +++ b/gcc/testsuite/g++.dg/lto/README @@ -24,9 +24,9 @@ $ g++ -o a_0.o a_1.o a_2.o Tests that do not need more than one file are a special case where there is a single file named 'foo_0.C'. -The only supported dg-lto-do option are 'compile', 'run' and 'link'. +The only supported dg-lto-do option are 'assemble', 'run' and 'link'. Additionally, these can only be used in the main file. If -'compile' is used, only the individual object files are +'assemble' is used, only the individual object files are generated. If 'link' is used, the final executable is generated but not executed (in this case, function main() needs to exist but it does not need to do anything). If 'run' is used, the diff --git a/gcc/testsuite/g++.dg/lto/pr52035_0.C b/gcc/testsuite/g++.dg/lto/pr52035_0.C new file mode 100644 index 0000000..3de4ea5 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/pr52035_0.C @@ -0,0 +1,14 @@ +// PR c++/52035 +// { dg-lto-do assemble } + +template struct QVector { + typedef T* iterator; + static void insert(int n); + typedef int size_type; +}; +template void QVector::insert(size_type n) {} +void error() +{ + int n; + QVector::insert(n); +}