From patchwork Mon Jan 16 21:29:53 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 136371 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 89A8AB6F7E for ; Tue, 17 Jan 2012 08:30:16 +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=1327354219; 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=15J5IBC lf3yRaYrYX+8OIQYKTKw=; b=exe7pRtQ2hATtcWrfPQflvLCTsHJyS4l4p1iR3E cbmhBETEo67sAVNKnM5L7GGUwDWeIq1bnXLrgZA7XFleWJFcnKaYDr3jUisZm0Aw qMPyuWqdyGJoUz3xDLCfdUkMeepDrM9C+2IjgBO3iKgWsMhNmPjagvETImS5aDNn 68bU= 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=AKF7k2HRugClvXBkxnOxtss0510g4UZISJ/a6xlOKY5cixBLqSZ4nL5ki8TqX6 Qy6NH5egmmAMlEGMOi++5pkIMHTHi3Fqr0Q+OPrIjktiWaLPdsFJ+UK0pHJtZcs2 aN9LzxGG1sKt4cakqV+8bbF/rwaKnLaVKY4+S4GN20NKA=; Received: (qmail 7619 invoked by alias); 16 Jan 2012 21:30:10 -0000 Received: (qmail 7608 invoked by uid 22791); 16 Jan 2012 21:30:08 -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; Mon, 16 Jan 2012 21:29:56 +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 q0GLTtLC014690 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 16 Jan 2012 16:29:56 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q0GLTtUj007907 for ; Mon, 16 Jan 2012 16:29:55 -0500 Received: from [0.0.0.0] (ovpn-113-35.phx2.redhat.com [10.3.113.35]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id q0GLTsNd029419 for ; Mon, 16 Jan 2012 16:29:54 -0500 Message-ID: <4F1496D1.4090502@redhat.com> Date: Mon, 16 Jan 2012 16:29:53 -0500 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:9.0) Gecko/20111222 Thunderbird/9.0 MIME-Version: 1.0 To: gcc-patches List Subject: C++ PATCH for c++/51827 (mangling error with PCH and LTO) 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 When outputting PCH/LTO, the compiler tries to generate mangled names for all decls before discarding language-specific data. But that doesn't make sense for templates, and leads to conflicts in this case. Fixed by refusing to mangle templates. Tested x86_64-pc-linux-gnu, applying to trunk. commit f984ce6e04c376a9eb7a2a69706489f5aa330573 Author: Jason Merrill Date: Mon Jan 16 14:19:32 2012 -0500 PR c++/51827 * mangle.c (mangle_decl): Don't mangle uninstantiated templates. diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index 5f2fa15..15b1aca 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -3330,7 +3330,21 @@ get_mangled_id (tree decl) void mangle_decl (const tree decl) { - tree id = get_mangled_id (decl); + tree id; + bool dep; + + /* Don't bother mangling uninstantiated templates. */ + ++processing_template_decl; + if (TREE_CODE (decl) == TYPE_DECL) + dep = dependent_type_p (TREE_TYPE (decl)); + else + dep = (DECL_LANG_SPECIFIC (decl) && DECL_TEMPLATE_INFO (decl) + && any_dependent_template_arguments_p (DECL_TI_ARGS (decl))); + --processing_template_decl; + if (dep) + return; + + id = get_mangled_id (decl); SET_DECL_ASSEMBLER_NAME (decl, id); if (G.need_abi_warning diff --git a/gcc/testsuite/g++.dg/pch/mangle1.C b/gcc/testsuite/g++.dg/pch/mangle1.C new file mode 100644 index 0000000..504fa2d --- /dev/null +++ b/gcc/testsuite/g++.dg/pch/mangle1.C @@ -0,0 +1,3 @@ +// { dg-options -std=c++11 } + +#include "mangle1.Hs" diff --git a/gcc/testsuite/g++.dg/pch/mangle1.Hs b/gcc/testsuite/g++.dg/pch/mangle1.Hs new file mode 100644 index 0000000..4d48c2e --- /dev/null +++ b/gcc/testsuite/g++.dg/pch/mangle1.Hs @@ -0,0 +1,8 @@ +// PR c++/51827 +// { dg-options "-flto -std=c++0x" } + +template struct S { }; +template struct T { + template T(S ); +}; +inline void f(T) { }