Commit 4666cd04 by Jason Merrill

re PR c++/26670 (attribute((packed)) sometimes not ignored for non-PODs)

        PR c++/26670
        * class.c (check_field_decls): Unset TYPE_PACKED (t) if one of the
        fields can't be packed.

From-SVN: r116555
parent bed02d89
...@@ -2906,10 +2906,13 @@ check_field_decls (tree t, tree *access_decls, ...@@ -2906,10 +2906,13 @@ check_field_decls (tree t, tree *access_decls,
if (TYPE_PACKED (t)) if (TYPE_PACKED (t))
{ {
if (!pod_type_p (type) && !TYPE_PACKED (type)) if (!pod_type_p (type) && !TYPE_PACKED (type))
warning {
(0, warning
"ignoring packed attribute on unpacked non-POD field %q+#D", (0,
x); "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) else if (TYPE_ALIGN (TREE_TYPE (x)) > BITS_PER_UNIT)
DECL_PACKED (x) = 1; DECL_PACKED (x) = 1;
} }
......
// 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));
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment