From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10427 invoked by alias); 25 Jun 2015 03:12:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 10398 invoked by uid 89); 25 Jun 2015 03:12:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-6.7 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 25 Jun 2015 03:12:38 +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 (Postfix) with ESMTPS id 031EFB82BB for ; Thu, 25 Jun 2015 03:12:36 +0000 (UTC) Received: from reynosa.quesejoda.com (vpn-63-154.rdu2.redhat.com [10.10.63.154]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5P3CZua001143; Wed, 24 Jun 2015 23:12:36 -0400 Message-ID: <558B71A3.3080004@redhat.com> Date: Thu, 25 Jun 2015 03:19:00 -0000 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: gcc-patches , jason merrill Subject: [patch] PR debug/66653: avoid late_global_decl on decl_type_context()s Content-Type: multipart/mixed; boundary="------------080301080700000206060806" X-SW-Source: 2015-06/txt/msg01752.txt.bz2 This is a multi-part message in MIME format. --------------080301080700000206060806 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1658 The problem here is that we are trying to call dwarf2out_late_global_decl() on a static variable in a template which has a type of TEMPLATE_TYPE_PARM: template class A { static __thread T a; }; We are calling late_global_decl because we are about to remove the unused static from the symbol table: /* See if the debugger can use anything before the DECL passes away. Perhaps it can notice a DECL that is now a constant and can tag the early DIE with an appropriate attribute. Otherwise, this is the last chance the debug_hooks have at looking at optimized away DECLs, since late_global_decl will subsequently be called from the contents of the now pruned symbol table. */ if (!decl_function_context (node->decl)) (*debug_hooks->late_global_decl) (node->decl); Since gen_type_die_with_usage() cannot handle TEMPLATE_TYPE_PARMs we ICE. I think we need to avoid calling late_global_decl on DECL's for which decl_type_context() is true, similarly to what we do for the call to early_global_decl in rest_of_decl_compilation: && !decl_function_context (decl) && !current_function_decl && DECL_SOURCE_LOCATION (decl) != BUILTINS_LOCATION && !decl_type_context (decl)) (*debug_hooks->early_global_decl) (decl); Presumably the old code did not run into this problem because the TEMPLATE_TYPE_PARAMs had been lowered by the time dwarf2out_decl was called, but here we are calling late_global_decl relatively early. The attached patch fixes the problem. Tested with --enable-languages=all. Ada had other issues, so I skipped it. OK for mainline? --------------080301080700000206060806 Content-Type: text/plain; charset=UTF-8; name="curr" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="curr" Content-length: 1591 Y29tbWl0IDMwMmY5OTc2YzUzYWEwOWU0MzFiZDU0ZjM3ZGJmZWFhMmM2YjJh Y2MKQXV0aG9yOiBBbGR5IEhlcm5hbmRleiA8YWxkeWhAcmVkaGF0LmNvbT4K RGF0ZTogICBXZWQgSnVuIDI0IDIwOjA0OjA5IDIwMTUgLTA3MDAKCiAgICAJ UFIgZGVidWcvNjY2NTMKICAgIAkqIGNncmFwaHVuaXQuYyAoYW5hbHl6ZV9m dW5jdGlvbnMpOiBEbyBub3QgY2FsbAogICAgCWRlYnVnX2hvb2tzLT5sYXRl X2dsb2JhbF9kZWNsIHdoZW4gZGVjbF90eXBlX2NvbnRleHQuCgpkaWZmIC0t Z2l0IGEvZ2NjL2NncmFwaHVuaXQuYyBi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