From patchwork Wed Oct 12 14:34:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 681345 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3svGbz0mgCz9s3s for ; Thu, 13 Oct 2016 01:35:10 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Y7uEhIhm; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=V4EkZ7Ov9LEok34Da4SbdajI41eClYlXIhRl8VbDu2k8iGncvkUQK 2QvSnVeacY2bfqRedldKEZB1wZqcMXfIzaPF3gHFexSojM4QKjUuXYnZ3rEdyQEV 5cwMqfPAU7D/MoUUycraxnqFPw+ab7d7u5ZUNvG893S+0OJbHj3nwU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=DzTAopss5PIAhng8tDwAdm9Kgbs=; b=Y7uEhIhm8/d/1Esm+cEj b1nu3S9bdLlFDC7ulOD9JvDzXvTaU1cDRRspG8QRTLAduCOrF8x/2mlj7aPzD1ve tCCYCRCXaNy4b+wpOwKFYJpPddvOfaPDJmNeBtv60wgImvnAZ5OHV+A2glEGDct5 vELfVbFkHNO9GXi+WlHI/ZU= Received: (qmail 85742 invoked by alias); 12 Oct 2016 14:35:02 -0000 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 Received: (qmail 85727 invoked by uid 89); 12 Oct 2016 14:35:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_PASS autolearn=no version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Oct 2016 14:34:51 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C0F47ABFC for ; Wed, 12 Oct 2016 14:34:48 +0000 (UTC) Date: Wed, 12 Oct 2016 16:34:48 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix PR77947 Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Bootstrapped and tested on x86_64-unknown-linux-gnu, applied. Richard. 2016-10-12 Richard Biener PR debug/77947 * cgraphunit.c (analyze_functions): Preserve cgraph nodes function context. * g++.dg/torture/pr77947.C: New testcase. Index: gcc/cgraphunit.c =================================================================== --- gcc/cgraphunit.c (revision 241033) +++ gcc/cgraphunit.c (working copy) @@ -1117,15 +1117,22 @@ analyze_functions (bool first_time) } /* If decl is a clone of an abstract function, - mark that abstract function so that we don't release its body. - The DECL_INITIAL() of that abstract function declaration - will be later needed to output debug info. */ + mark that abstract function so that we don't release its body. + The DECL_INITIAL() of that abstract function declaration + will be later needed to output debug info. */ if (DECL_ABSTRACT_ORIGIN (decl)) { cgraph_node *origin_node = cgraph_node::get_create (DECL_ABSTRACT_ORIGIN (decl)); origin_node->used_as_abstract_origin = true; } + /* Preserve a functions function context node. It will + later be needed to output debug info. */ + if (tree fn = decl_function_context (decl)) + { + cgraph_node *origin_node = cgraph_node::get_create (fn); + enqueue_node (origin_node); + } } else { Index: gcc/testsuite/g++.dg/torture/pr77947.C =================================================================== --- gcc/testsuite/g++.dg/torture/pr77947.C (revision 0) +++ gcc/testsuite/g++.dg/torture/pr77947.C (revision 0) @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-additional-options "-g" } + +class A +{ +public: + virtual bool m_fn1 () const = 0; +}; +class B +{ + const A *m_fn2 () const; +}; +inline const A * +B::m_fn2 () const +{ + class C : A + { + bool + m_fn1 () const + { + } + C () {} + }; +} +void +fn1 (A &p1) +{ + p1.m_fn1 (); +}