summaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-28 10:34:30 +0000
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>2005-11-28 10:34:30 +0000
commitc2ab04f9e57d248094640e87fdfe3f9454a9cd5d (patch)
tree7e925b64a93bd395a2f07912807080dfbe0ecd38 /gcc/c-common.c
parent4e62d878778233548fdf5049e7a2b621b88928ee (diff)
downloadgcc-c2ab04f9e57d248094640e87fdfe3f9454a9cd5d.tar.gz
.:
PR c++/21166 * c-decl.c (finish_struct): Only set DECL_PACKED on a field when its natural alignment is > BITS_PER_UNIT. * stor-layout.c (finalize_type_size): Revert my patch of 2005-08-08. * c-common.c (handle_packed_attribute): Ignore packing on a field whose type is naturally char aligned. cp: PR c++/21166 * class.c (check_field_decls): Only set DECL_PACKED on a field when its natural alignment is > BITS_PER_UNIT. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@107599 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/c-common.c b/gcc/c-common.c
index b416a5d3648..43c147b3068 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -4065,17 +4065,23 @@ handle_packed_attribute (tree *node, tree name, tree ARG_UNUSED (args),
struct Foo {
struct Foo const *ptr; // creates a variant w/o packed flag
- } __ attribute__((packed)); // packs it now.
- */
+ } __ attribute__((packed)); // packs it now.
+ */
tree probe;
for (probe = *node; probe; probe = TYPE_NEXT_VARIANT (probe))
TYPE_PACKED (probe) = 1;
}
-
}
else if (TREE_CODE (*node) == FIELD_DECL)
- DECL_PACKED (*node) = 1;
+ {
+ if (TYPE_ALIGN (TREE_TYPE (*node)) <= BITS_PER_UNIT)
+ warning (OPT_Wattributes,
+ "%qE attribute ignored for field of type %qT",
+ name, TREE_TYPE (*node));
+ else
+ DECL_PACKED (*node) = 1;
+ }
/* We can't set DECL_PACKED for a VAR_DECL, because the bit is
used for DECL_REGISTER. It wouldn't mean anything anyway.
We can't set DECL_PACKED on the type of a TYPE_DECL, because