* 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
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;
}
--- /dev/null
+// 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));