We need to call decl_attributes when creating the fields for a composite
type.
PR c/117806
gcc/c/ChangeLog:
* c-typeck.cc (composite_type_internal): Call decl_attributes.
gcc/testsuite/ChangeLog:
* gcc.dg/pr117806.c: New test.
DECL_ATTRIBUTES (f) = DECL_ATTRIBUTES (a);
C_DECL_VARIABLE_SIZE (f) = C_TYPE_VARIABLE_SIZE (t);
+ decl_attributes (&f, DECL_ATTRIBUTES (f), 0);
+
finish_decl (f, input_location, NULL, NULL, NULL);
if (DECL_C_BIT_FIELD (a))
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-std=c23" } */
+
+struct Test {
+ double D __attribute__((packed,aligned(4)));
+} x;
+struct Test {
+ double D __attribute__((packed,aligned(4)));
+} x;
+struct Test {
+ double D __attribute__((packed,aligned(4)));
+} x;
+