]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Fix ICE type variant differs by TYPE_PACKED [PR117621]
authorIain Buclaw <ibuclaw@gdcproject.org>
Sun, 23 Mar 2025 11:57:27 +0000 (12:57 +0100)
committerIain Buclaw <ibuclaw@gdcproject.org>
Sun, 23 Mar 2025 12:03:15 +0000 (13:03 +0100)
Introduced by r13-1104-gf4c3ce32fa54c1, which had an accidental self
assignment of TYPE_PACKED when it should have been assigned to the
type's variants.

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.

(cherry picked from commit a12dd79ff4e469652be6d8ef501e1d70178b44cd)

gcc/d/types.cc
gcc/testsuite/gdc.dg/pr117621.d [new file with mode: 0644]

index 9fa2f888cb22551cc8b82c2984e6965c2b2d2010..02f69af166d694181bbb31937329bde981af6eee 100644 (file)
@@ -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 (file)
index 0000000..f0b96cb
--- /dev/null
@@ -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);
+}