From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id EC2E43858280; Fri, 23 Jun 2023 10:30:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EC2E43858280 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687516205; bh=nRGPuKtFA7KqNDp3i9nZCcpREPeJlZv3IjQ63+euuY8=; h=From:To:Subject:Date:From; b=PYkXspy8DDyesfEk+UKOQJR0YQrhuvDsCERFPgnGx0Dc1I1ogq+5k0aIF9Zmb9fxw gqnYdrz3IMCdmquV3D5z2Xdi/ouDHBltzSp+kQcfkwP9uRZ8DBo2y0kpsWfNFPefsr nApQui8+hcQgbFX/ujdentDQRCHMAfn7kwwY6eFs= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-7468] debug/110295 - mixed up early/late debug for member DIEs X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: b0856bb588c76e16a518b459a8c9a012dc2b4e21 X-Git-Newrev: 0b69fea6cf12d82f82439f26527ef8721e24411e Message-Id: <20230623103005.EC2E43858280@sourceware.org> Date: Fri, 23 Jun 2023 10:30:05 +0000 (GMT) List-Id: https://gcc.gnu.org/g:0b69fea6cf12d82f82439f26527ef8721e24411e commit r13-7468-g0b69fea6cf12d82f82439f26527ef8721e24411e Author: Richard Biener Date: Mon Jun 19 09:23:16 2023 +0200 debug/110295 - mixed up early/late debug for member DIEs 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. 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. (cherry picked from commit 963f87f8a65ec82f503ac4334a3da83b0a8a43b2) Diff: --- gcc/dwarf2out.cc | 3 ++- gcc/testsuite/g++.dg/debug/pr110295.C | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 1a0015ce00f..4ab625498c9 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -26534,7 +26534,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>(); }