diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index e1c35325889..a2acfd1d356 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -26424,10 +26424,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) { @@ -26441,8 +26441,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 index 00000000000..fc1e2e742a1 --- /dev/null +++ b/gcc/testsuite/g++.dg/debug/pr101533.C @@ -0,0 +1,11 @@ +// { dg-do compile } +// { dg-options "-g" } + +template class T +{ + typedef struct {} a __attribute__((aligned)); +}; +void f () +{ + T(); +}