From patchwork Mon Jun 19 10:15:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 109888 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2891039vqr; Mon, 19 Jun 2023 03:16:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5wOryaQ6B7mCFwHnK3IChmCNhO+Cw8iqwapZ4rSblGfJpojc/2b16IO0mi/JyBuhJfyz55 X-Received: by 2002:a17:907:806:b0:974:5e14:29c0 with SMTP id wv6-20020a170907080600b009745e1429c0mr9532975ejb.21.1687169770746; Mon, 19 Jun 2023 03:16:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687169770; cv=none; d=google.com; s=arc-20160816; b=lw5XV2CQ0LK4N1MQNPYU+YZ0vD/nT5QFxN/9rxv4LjVaWpiOlHAbF2FlZna6Sbahyq VQLBi01gI6d0KYd1nimGluueHTOL+q67qtyggXLgrZmmg5g/zYLwWQATBkT/k3tmgfUd gNlzkxNpZ2X+QaYHM1Nyp+PVWTznmwWMUIpNnix3zmQmOZBJn/oBg54nYCdrsi/sAZFi d6/XSEosOwoqm7+3M0+RaL41sPEXl3xj1XSA/56LtrPuWdtydqT6ExTzw14s4anCl6ie ecFrzt6FdnbKtLItxiHl8JbFbFL+Zson1aS0ivqURTdnVhXfnKeJ4FW0muUX7FJXocG2 pZOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:sender:errors-to:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:user-agent:subject:cc:to:date:dmarc-filter :delivered-to:dkim-signature:dkim-filter; bh=Q7wwUT7kzomNXXc+6cm/eVM0m4LVGL0N0mRVG64cCQo=; b=g1RSdn3+Qtl1cisY1Eqlw35AwxOhz0Oen8szpVV/+tcY822fsjPwZCGub9Le4BoIub 3gNVRjYVIV8Dd4SnDo/UtpBro0p1HAEEhWm9UFOI2mCBEUwcBbGWfwU1fWWhSEHvEIVG pOk/S/KcYOO+oz0JpXeDaakAb6U+zm3sKXw3IWx6GyWTgcQJpmBIEZENYimbDae/m4AZ G1640Us/sFGpsDRHeb6hW48ZDWmP+PtZXxPTHTTgiATzBVgiBpTuU5znMKI3syvq1xsw iRLFi8h5wKnjkP8zJO5nNCVTfuw38f9pTAQZj/80hXwRMdWQdDoOjYWqgzTf7miHlIco eS3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Pgz7VwHr; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id k7-20020a17090646c700b00987b4c9cf55si2529633ejs.489.2023.06.19.03.16.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jun 2023 03:16:10 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Pgz7VwHr; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 63E4F385840D for ; Mon, 19 Jun 2023 10:16:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 63E4F385840D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687169769; bh=Q7wwUT7kzomNXXc+6cm/eVM0m4LVGL0N0mRVG64cCQo=; h=Date:To:cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Pgz7VwHrTtR7fumvb8R+rUJEVnLP9AZhhf7YPUg/8RqsWNIXnHcTPhE4ld355z8y8 Rdoy8mx+TOKv61s+PsW16njkTbLXgmD0nAiSTfo3ASxkDzl7Y6vtmjdDjC+uFvBRek xJax+BUZyri3gJuiWf4uXNPp8JzQ0X/xVWcXOyW0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id D5C1C3858D28 for ; Mon, 19 Jun 2023 10:15:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D5C1C3858D28 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 0DEE41F38D; Mon, 19 Jun 2023 10:15:26 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 009A22C141; Mon, 19 Jun 2023 10:15:25 +0000 (UTC) Date: Mon, 19 Jun 2023 10:15:25 +0000 (UTC) To: gcc-patches@gcc.gnu.org cc: jason@redhat.com Subject: [PATCH] debug/110295 - mixed up early/late debug for member DIEs User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" Message-Id: <20230619101609.63E4F385840D@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769125729586628818?= X-GMAIL-MSGID: =?utf-8?q?1769125729586628818?= When we process a scope typedef during early debug creation and we have already created a DIE for the type when the decl is TYPE_DECL_IS_STUB and this DIE is still in limbo we end up just re-parenting that type DIE instead of properly creating a DIE for the decl, eventually picking up the now completed type and creating DIEs for the members. Instead this is currently defered to the second time we come here, when we annotate the DIEs with locations late where now the type DIE is no longer in limbo and we fall through doing the job for the decl. The following makes sure we perform the necessary early tasks for this by continuing with the decl DIE creation after setting a parent for the limbo type DIE. [LTO] Bootstrapped on x86_64-unknown-linux-gnu. OK for trunk? Thanks, Richard. PR debug/110295 * dwarf2out.cc (process_scope_var): Continue processing the decl after setting a parent in case the existing DIE was in limbo. * g++.dg/debug/pr110295.C: New testcase. --- gcc/dwarf2out.cc | 3 ++- gcc/testsuite/g++.dg/debug/pr110295.C | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/debug/pr110295.C diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index d89ffa66847..e70c47cec8d 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -26533,7 +26533,8 @@ process_scope_var (tree stmt, tree decl, tree origin, dw_die_ref context_die) if (die != NULL && die->die_parent == NULL) add_child_die (context_die, die); - else if (TREE_CODE (decl_or_origin) == IMPORTED_DECL) + + if (TREE_CODE (decl_or_origin) == IMPORTED_DECL) { if (early_dwarf) dwarf2out_imported_module_or_decl_1 (decl_or_origin, DECL_NAME (decl_or_origin), diff --git a/gcc/testsuite/g++.dg/debug/pr110295.C b/gcc/testsuite/g++.dg/debug/pr110295.C new file mode 100644 index 00000000000..10cad557095 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/pr110295.C @@ -0,0 +1,19 @@ +// { dg-do compile } +// { dg-options "-g" } + +template +struct QCachedT +{ + void operator delete(void *, T *) {} +}; +template +void exercise() +{ + struct thing_t + : QCachedT + { + }; + thing_t *list[1]; + new thing_t; // { dg-warning "" } +} +int main() { exercise<1>(); }