From patchwork Mon Sep 13 21:09:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 64658 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 0C1CBB6F10 for ; Tue, 14 Sep 2010 07:09:19 +1000 (EST) Received: (qmail 28925 invoked by alias); 13 Sep 2010 21:09:17 -0000 Received: (qmail 28914 invoked by uid 22791); 13 Sep 2010 21:09:16 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_FN, 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, 13 Sep 2010 21:09:11 +0000 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o8DL9AUi011542 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 13 Sep 2010 17:09:10 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o8DL99dC020654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 13 Sep 2010 17:09:09 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o8DL9sKs016137; Mon, 13 Sep 2010 23:09:54 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o8DL9rTW016136; Mon, 13 Sep 2010 23:09:53 +0200 Date: Mon, 13 Sep 2010 23:09:53 +0200 From: Jakub Jelinek To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, Dodji Seketeli Subject: [PATCH] Fix dwarf2out_finish ICE (PR debug/45660) Message-ID: <20100913210953.GF1269@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes 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 Hi! On the attached testcase cc1plus ICEs in dwarf2out_finish, because when creating DIE for i we first create DIE for T typedef (thus it is created as limbo DIE node), and only afterwards create the containing class' DIE. When processing its T member, TREE_ASM_WRITTEN is already set, thus nothing sets the T DIE's die_parent and in dwarf2out_finish we ICE because die_parent is still NULL, but its context isn't fndecl or namespace, but a class. Fixed by making sure to create DIE for the class before creating DIE for the return type. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.5? 2010-09-13 Jakub Jelinek PR debug/45660 * dwarf2out.c (gen_decl_die): Call gen_type_die for origin before gen_type_die for function/method return type. * g++.dg/debug/pr45660.C: New test. Jakub --- gcc/dwarf2out.c.jj 2010-09-09 10:17:41.000000000 +0200 +++ gcc/dwarf2out.c 2010-09-13 20:18:24.000000000 +0200 @@ -20596,16 +20596,20 @@ gen_decl_die (tree decl, tree origin, dw else if (debug_info_level > DINFO_LEVEL_TERSE) { /* Before we describe the FUNCTION_DECL itself, make sure that we - have described its return type. */ + have its containing type. */ + if (!origin) + origin = decl_class_context (decl); + if (origin != NULL_TREE) + gen_type_die (origin, context_die); + + /* And its return type. */ gen_type_die (TREE_TYPE (TREE_TYPE (decl)), context_die); /* And its virtual context. */ if (DECL_VINDEX (decl) != NULL_TREE) gen_type_die (DECL_CONTEXT (decl), context_die); - /* And its containing type. */ - if (!origin) - origin = decl_class_context (decl); + /* Make sure we have a member DIE for decl. */ if (origin != NULL_TREE) gen_type_die_for_member (origin, decl, context_die); --- gcc/testsuite/g++.dg/debug/pr45660.C.jj 2010-09-13 19:57:39.000000000 +0200 +++ gcc/testsuite/g++.dg/debug/pr45660.C 2010-09-13 19:52:49.000000000 +0200 @@ -0,0 +1,16 @@ +// PR debug/45660 +// { dg-do compile } +// { dg-options "-g -fno-inline" } + +void +test () +{ + struct S + { + typedef void (**T) (void); + static T i (void) { return 0; } + }; + S s; + if (s.i ()) + *s.i () = 0; +}