From patchwork Thu Jun 7 20:29:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 163670 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 62A6FB6FA4 for ; Fri, 8 Jun 2012 06:29:29 +1000 (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=1339705770; h=Comment: DomainKey-Signature: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=Ye+Np3x 2kd/suXbI+AEXQl4mDFs=; b=I7OelQJNFCrFALxSswUuy67SREtm5cfOIsvqkFY lYdOKENtNL5cgatGqlA+YTD6bZbkwp8sJRjiSkJgcXlPj8OhY40h34KG40/Vn5zi yP3lV3ixP06yNynt0fntDbqsnq/VMozsmT8utxKFoOzxK8pCw/VR7aDQBbPmFT5Y iXCM= 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: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=gc/dTKyLp3otY102Geujb65uVmeCHKXl2gYcpnvVPBkL90q+ZnvjfX8dYlniOW fmZSml+YptDcYmulq/fucq18juuodroZJXowzEHrTbwFvSkMlgIAOMxBPAxb1ISy YVe0wDRp3Wy/a+vimf0ncGgffYnInSezDhZ4zYph3tc5c=; Received: (qmail 4743 invoked by alias); 7 Jun 2012 20:29:27 -0000 Received: (qmail 4732 invoked by uid 22791); 7 Jun 2012 20:29:27 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, 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, 07 Jun 2012 20:29:09 +0000 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q57KT8kH024277 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 7 Jun 2012 16:29:08 -0400 Received: from [10.3.113.104] (ovpn-113-104.phx2.redhat.com [10.3.113.104]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q57KT7Rl003070; Thu, 7 Jun 2012 16:29:08 -0400 Message-ID: <4FD10F13.2040605@redhat.com> Date: Thu, 07 Jun 2012 16:29:07 -0400 From: Jason Merrill User-Agent: Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: gcc-patches List , Richard Guenther Subject: C++ PATCH for c++/53599 (ICE with local class in 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 problem here was that when we instantiate G::bar, we want to instantiate F, and end up improperly pushing the declaration inside G, which leads to the ICE. Adjusting the call to pushclass is enough to fix this, which is what I propose doing for the 4.7 branch. For 4.8 I'm going to do more. Richard: I think we need to resolve 53599 for 4.7.1, either by reverting the fix for 53137 or applying this patch. Do you have a preference? commit ec323a89482ecd0b31124aeb3d486da48b0a4602 Author: Jason Merrill Date: Thu Jun 7 15:16:05 2012 -0400 PR c++/53599 * pt.c (lookup_template_class_1): Use ts_global. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index a2d8374..7f5682d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -7564,7 +7564,7 @@ lookup_template_class_1 (tree d1, tree arglist, tree in_decl, tree context, /* A local class. Make sure the decl gets registered properly. */ if (context == current_function_decl) - pushtag (DECL_NAME (gen_tmpl), t, /*tag_scope=*/ts_current); + pushtag (DECL_NAME (gen_tmpl), t, /*tag_scope=*/ts_global); if (comp_template_args (CLASSTYPE_TI_ARGS (template_type), arglist)) /* This instantiation is another name for the primary diff --git a/gcc/testsuite/g++.dg/template/local7.C b/gcc/testsuite/g++.dg/template/local7.C new file mode 100644 index 0000000..3045534 --- /dev/null +++ b/gcc/testsuite/g++.dg/template/local7.C @@ -0,0 +1,15 @@ +// PR c++/53599 + +template +int foo () +{ + struct F; + struct G + { + static int F::* bar(); + }; + + return sizeof(G); +} + +int z = foo ();