]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
debug/101533 - ICE with variant typedef DIE generation
authorRichard Biener <rguenther@suse.de>
Wed, 5 Mar 2025 13:24:50 +0000 (14:24 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 2 Apr 2025 07:23:07 +0000 (09:23 +0200)
There's a sanity check in gen_type_die_with_usage that trips
unnecessarily for a case where the relevant DIE has already been
generated successfully in other ways.  The following keys the
existing TREE_ASM_WRITTEN check on the correct object, honoring
this and does nothing instead of ICEing for the testcase at hand.

PR debug/101533
* dwarf2out.cc (gen_type_die_with_usage): When we have
output the typedef already do nothing for a typedef variant.
Do not set TREE_ASM_WRITTEN on the type.

* g++.dg/debug/pr101533.C: New testcase.

(cherry picked from commit 99a3f013c3bb8bc022ca488b40aa18fd97b5224d)

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

index 1b0e8b5a5b298fef4b895970ca301305eadc3f3f..e1398c61cd59f908dd47a07ae0c663f8f1fe1242 100644 (file)
@@ -26300,10 +26300,10 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
      for the parent typedef which TYPE is a type of.  */
   if (typedef_variant_p (type))
     {
-      if (TREE_ASM_WRITTEN (type))
+      tree name = TYPE_NAME (type);
+      if (TREE_ASM_WRITTEN (name))
        return;
 
-      tree name = TYPE_NAME (type);
       tree origin = decl_ultimate_origin (name);
       if (origin != NULL && origin != name)
        {
@@ -26317,8 +26317,6 @@ gen_type_die_with_usage (tree type, dw_die_ref context_die,
       /* Give typedefs the right scope.  */
       context_die = scope_die_for (type, context_die);
 
-      TREE_ASM_WRITTEN (type) = 1;
-
       gen_decl_die (name, NULL, NULL, context_die);
       return;
     }
diff --git a/gcc/testsuite/g++.dg/debug/pr101533.C b/gcc/testsuite/g++.dg/debug/pr101533.C
new file mode 100644 (file)
index 0000000..fc1e2e7
--- /dev/null
@@ -0,0 +1,11 @@
+// { dg-do compile }
+// { dg-options "-g" }
+
+template <typename> class T
+{
+  typedef struct {} a __attribute__((aligned));
+};
+void f ()
+{
+  T<int>();
+}