aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMartin Uecker <uecker@tugraz.at>2024-11-29 17:04:36 +0100
committerMartin Uecker <uecker@gcc.gnu.org>2024-11-30 08:40:24 +0100
commit1539bcd19c5928d8359722c532dfcc7a26a16dda (patch)
treed97bf53ffeb8b67084aa2ce3642c36c4d39891e4 /gcc
parent1701efd5c848f56cf9a469c5bf42dd0bca675e0a (diff)
downloadgcc-1539bcd19c5928d8359722c532dfcc7a26a16dda.zip
gcc-1539bcd19c5928d8359722c532dfcc7a26a16dda.tar.gz
gcc-1539bcd19c5928d8359722c532dfcc7a26a16dda.tar.bz2
c: Set attributes for fields when forming a composite type [PR117806]
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/c/c-typeck.cc2
-rw-r--r--gcc/testsuite/gcc.dg/pr117806.c13
2 files changed, 15 insertions, 0 deletions
diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc
index 611dacc..e60f89a 100644
--- a/gcc/c/c-typeck.cc
+++ b/gcc/c/c-typeck.cc
@@ -791,6 +791,8 @@ composite_type_internal (tree t1, tree t2, struct composite_cache* cache)
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))
diff --git a/gcc/testsuite/gcc.dg/pr117806.c b/gcc/testsuite/gcc.dg/pr117806.c
new file mode 100644
index 0000000..bc2c8c6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr117806.c
@@ -0,0 +1,13 @@
+/* { 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;
+