diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-29 06:55:35 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-08-29 06:55:35 +0000 |
commit | adb8ba10b561488e3359be8e0f921e5ceb444707 (patch) | |
tree | a25aa21ee2d5af03a666508c54f5c5ef21973bb7 | |
parent | dc02da7f70bd7dfc9b7dc176a1ffbe47e9c07830 (diff) |
PR c++/26670
* class.c (check_field_decls): Unset TYPE_PACKED (t) if one of the
fields can't be packed.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116555 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/class.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/ext/packed11.C | 13 |
2 files changed, 20 insertions, 4 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 18996a043b8..550edffaaab 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2906,10 +2906,13 @@ check_field_decls (tree t, tree *access_decls, if (TYPE_PACKED (t)) { if (!pod_type_p (type) && !TYPE_PACKED (type)) - warning - (0, - "ignoring packed attribute on unpacked non-POD field %q+#D", - x); + { + warning + (0, + "ignoring packed attribute because of unpacked non-POD field %q+#D", + x); + TYPE_PACKED (t) = 0; + } else if (TYPE_ALIGN (TREE_TYPE (x)) > BITS_PER_UNIT) DECL_PACKED (x) = 1; } diff --git a/gcc/testsuite/g++.dg/ext/packed11.C b/gcc/testsuite/g++.dg/ext/packed11.C new file mode 100644 index 00000000000..e75845d9315 --- /dev/null +++ b/gcc/testsuite/g++.dg/ext/packed11.C @@ -0,0 +1,13 @@ +// PR c++/26670 + +struct nonpod { + nonpod(); +}; + +struct nonpod_pack { + nonpod n; // { dg-warning "ignoring packed attribute" } +} __attribute__ ((packed)); + +struct nonpod_pack2 { + nonpod_pack p; // { dg-warning "ignoring packed attribute" } +} __attribute__ ((packed)); |