From patchwork Thu Jun 23 16:54:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 101657 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 62A7BB6F86 for ; Fri, 24 Jun 2011 02:54:31 +1000 (EST) Received: (qmail 16383 invoked by alias); 23 Jun 2011 16:54:29 -0000 Received: (qmail 16374 invoked by uid 22791); 23 Jun 2011 16:54:29 -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; Thu, 23 Jun 2011 16:54:12 +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 p5NGsBvR024030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 23 Jun 2011 12:54:11 -0400 Received: from [127.0.0.1] (ovpn-113-125.phx2.redhat.com [10.3.113.125]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p5NGsA5C007094; Thu, 23 Jun 2011 12:54:11 -0400 Message-ID: <4E036FB2.5050706@redhat.com> Date: Thu, 23 Jun 2011 12:54:10 -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 , Jakub Jelinek Subject: C++ PATCH for c++/49507 (ICE with template dtor defaulted out of class) 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, if we're going to synthesize the dtor in instantiate_decl, we need to not also do it directly in mark_used. Tested x86_64-pc-linux-gnu, applying to trunk and 4.6.1 (since Jakub asked about fixing this for 4.6.1 and it seems safe). commit 2c7d73cc244974ee3e483cdfcddc210fdf98e25a Author: Jason Merrill Date: Thu Jun 23 11:06:43 2011 -0400 PR c++/49507 * decl2.c (mark_used): Don't call synthesize_method for functions defaulted outside the class. diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index d2f075d..9e5a229 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -4297,6 +4297,9 @@ mark_used (tree decl) if (TREE_CODE (decl) == FUNCTION_DECL && DECL_NONSTATIC_MEMBER_FUNCTION_P (decl) && DECL_DEFAULTED_FN (decl) + /* A function defaulted outside the class is synthesized either by + cp_finish_decl or instantiate_decl. */ + && !DECL_DEFAULTED_OUTSIDE_CLASS_P (decl) && ! DECL_INITIAL (decl)) { /* Remember the current location for a function we will end up diff --git a/gcc/testsuite/g++.dg/cpp0x/defaulted30.C b/gcc/testsuite/g++.dg/cpp0x/defaulted30.C new file mode 100644 index 0000000..0bf4425 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/defaulted30.C @@ -0,0 +1,16 @@ +// PR c++/49507 +// { dg-options -std=c++0x } + +template +struct ConcretePoolKey +{ + virtual ~ConcretePoolKey(); +}; + +template +ConcretePoolKey::~ConcretePoolKey() = default; + +int main() +{ + ConcretePoolKey foo; +}