Hi,

r13-1104-gf4c3ce32fa54c1 introduced a regression, which had an
accidental self assignment of TYPE_PACKED when it should have been
assigned to the type's variants. This patch fixes that.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32, committed
to mainline, and backported to releases/gcc-14 and releases/gcc-13.

Regards,
Iain.

---
        PR d/117621

gcc/d/ChangeLog:

        * types.cc (finish_aggregate_type): Propagate TYPE_PACKED to variants.

gcc/testsuite/ChangeLog:

        * gdc.dg/pr117621.d: New test.
---
 gcc/d/types.cc                  |  2 +-
 gcc/testsuite/gdc.dg/pr117621.d | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gdc.dg/pr117621.d

diff --git a/gcc/d/types.cc b/gcc/d/types.cc
index 47ef66c2580..98074f1fb68 100644
--- a/gcc/d/types.cc
+++ b/gcc/d/types.cc
@@ -704,7 +704,7 @@ finish_aggregate_type (unsigned structsize, unsigned 
alignsize, tree type)
       TYPE_LANG_SPECIFIC (t) = TYPE_LANG_SPECIFIC (type);
       TYPE_SIZE (t) = TYPE_SIZE (type);
       TYPE_SIZE_UNIT (t) = TYPE_SIZE_UNIT (type);
-      TYPE_PACKED (type) = TYPE_PACKED (type);
+      TYPE_PACKED (t) = TYPE_PACKED (type);
       SET_TYPE_ALIGN (t, TYPE_ALIGN (type));
       TYPE_USER_ALIGN (t) = TYPE_USER_ALIGN (type);
     }
diff --git a/gcc/testsuite/gdc.dg/pr117621.d b/gcc/testsuite/gdc.dg/pr117621.d
new file mode 100644
index 00000000000..f0b96cbff2c
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr117621.d
@@ -0,0 +1,11 @@
+// { dg-do "compile" }
+// { dg-options "-g" }
+void pr117621()
+{
+    auto fun()(inout int)
+    {
+        struct S {}
+        return inout(S)();
+    }
+    auto s = fun(0);
+}
-- 
2.43.0

Reply via email to