]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
debug/110295 - mixed up early/late debug for member DIEs
authorRichard Biener <rguenther@suse.de>
Mon, 19 Jun 2023 07:23:16 +0000 (09:23 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 15 Dec 2023 12:17:28 +0000 (13:17 +0100)
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.c (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)

gcc/dwarf2out.c
gcc/testsuite/g++.dg/debug/pr110295.C [new file with mode: 0644]

index c3dab15026dc986c8bb0ff21216f7b09d2ecf85a..bd6c00957ac41b630d22edad59bbb2e4aa1c687d 100644 (file)
@@ -26120,7 +26120,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 (file)
index 0000000..173df8a
--- /dev/null
@@ -0,0 +1,19 @@
+// { dg-do compile }
+// { dg-options "-g" }
+
+template <typename T>
+struct QCachedT
+{
+  void operator delete(void *, T *) {}
+};
+template<int a>
+void exercise()
+{
+  struct thing_t
+    : QCachedT<thing_t>
+  {
+  };
+  thing_t *list[1];
+  new thing_t;
+}
+int main() { exercise<1>(); }