From 88d787e7a0cd330eaadee3fb19ff33a62162f53c Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Fri, 30 Jul 2010 15:49:34 +0000 Subject: [PATCH] re PR c++/45112 (Aligned attribute on static class member definition ignored) gcc/ PR c++/45112 * cp/decl.c (duplicate_decls): Merge DECL_USER_ALIGN and DECL_PACKED. gcc/testsuite/ PR c++/45112 * testsuite/g++.dg/pr45112.C: New test. From-SVN: r162716 --- gcc/ChangeLog | 5 +++++ gcc/cp/decl.c | 4 ++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/pr45112.C | 12 ++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/g++.dg/pr45112.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c94bf560a4a..faa152206b5 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2010-07-30 Ulrich Weigand + + PR c++/45112 + * cp/decl.c (duplicate_decls): Merge DECL_USER_ALIGN and DECL_PACKED. + 2010-07-30 Jakub Jelinek PR debug/45055 diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 3aaa20c0ed3..4e4a27786b8 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -2113,6 +2113,10 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) SET_DECL_INIT_PRIORITY (olddecl, DECL_INIT_PRIORITY (newdecl)); DECL_HAS_INIT_PRIORITY_P (olddecl) = 1; } + /* Likewise for DECL_USER_ALIGN and DECL_PACKED. */ + DECL_USER_ALIGN (olddecl) = DECL_USER_ALIGN (newdecl); + if (TREE_CODE (newdecl) == FIELD_DECL) + DECL_PACKED (olddecl) = DECL_PACKED (newdecl); /* The DECL_LANG_SPECIFIC information in OLDDECL will be replaced with that from NEWDECL below. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 2fded2a5233..132433051e5 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2010-07-30 Ulrich Weigand + + PR c++/45112 + * testsuite/g++.dg/pr45112.C: New test. + 2010-07-30 Jakub Jelinek PR debug/45055 diff --git a/gcc/testsuite/g++.dg/pr45112.C b/gcc/testsuite/g++.dg/pr45112.C new file mode 100644 index 00000000000..34dd3e1bcd8 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr45112.C @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +struct JSString +{ + unsigned char mLength; + static JSString unitStringTable[]; +}; + +JSString JSString::unitStringTable[] __attribute__ ((aligned (8))) = { 1 }; + +int bug [__alignof__ (JSString::unitStringTable) >= 8 ? 1 : -1]; +