Hi,
This patch fixes PR123264.
The lack of TYPE_NAME being set in qualified struct types meant that
dump_generic_node got stuck in an infinite loop between
print_struct_decl and dump_function_declaration.
Regstrapped on x86_64-linux-gnu, committed to mainline, and backported
to releases/gcc-13, gcc-14, and gcc-15.
Regards,
Iain.
---
PR d/123264
gcc/d/ChangeLog:
* types.cc (finish_aggregate_type): Propagate TYPE_NAME to all
TYPE_NEXT_VARIANT types.
gcc/testsuite/ChangeLog:
* gdc.dg/pr123264.d: New test.
---
gcc/d/types.cc | 1 +
gcc/testsuite/gdc.dg/pr123264.d | 8 ++++++++
2 files changed, 9 insertions(+)
create mode 100644 gcc/testsuite/gdc.dg/pr123264.d
diff --git a/gcc/d/types.cc b/gcc/d/types.cc
index b09c262fc86..078ac4c9e9b 100644
--- a/gcc/d/types.cc
+++ b/gcc/d/types.cc
@@ -707,6 +707,7 @@ finish_aggregate_type (unsigned structsize, unsigned
alignsize, tree type)
if (t == type)
continue;
+ TYPE_NAME (t) = TYPE_NAME (type);
TYPE_FIELDS (t) = TYPE_FIELDS (type);
TYPE_LANG_SPECIFIC (t) = TYPE_LANG_SPECIFIC (type);
TYPE_SIZE (t) = TYPE_SIZE (type);
diff --git a/gcc/testsuite/gdc.dg/pr123264.d b/gcc/testsuite/gdc.dg/pr123264.d
new file mode 100644
index 00000000000..a786c054e74
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr123264.d
@@ -0,0 +1,8 @@
+// { dg-do compile }
+// { dg-options "-fdump-tree-original" }
+struct S123264
+{
+ void infinite(const S123264) { }
+ auto fn = &infinite;
+}
+// { dg-final { scan-tree-dump "const struct S123264" "original" } }
--
2.43.0