Commit 22002050 by Jason Merrill Committed by Jason Merrill

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

        PR c++/26670
        * class.c (check_field_decls): Don't unset TYPE_PACKED until all
        the fields have been processed.

From-SVN: r116591
parent 884f22e3
2006-08-30 Jason Merrill <jason@redhat.com>
PR c++/26670
* class.c (check_field_decls): Don't unset TYPE_PACKED until all
the fields have been processed.
2006-08-29 Andrew Pinski <pinskia@physics.uc.edu> 2006-08-29 Andrew Pinski <pinskia@physics.uc.edu>
PR C++/28349 PR C++/28349
......
...@@ -2795,6 +2795,7 @@ check_field_decls (tree t, tree *access_decls, ...@@ -2795,6 +2795,7 @@ check_field_decls (tree t, tree *access_decls,
tree *next; tree *next;
bool has_pointers; bool has_pointers;
int any_default_members; int any_default_members;
int cant_pack = 0;
/* Assume there are no access declarations. */ /* Assume there are no access declarations. */
*access_decls = NULL_TREE; *access_decls = NULL_TREE;
...@@ -2911,7 +2912,7 @@ check_field_decls (tree t, tree *access_decls, ...@@ -2911,7 +2912,7 @@ check_field_decls (tree t, tree *access_decls,
(0, (0,
"ignoring packed attribute because of unpacked non-POD field %q+#D", "ignoring packed attribute because of unpacked non-POD field %q+#D",
x); x);
TYPE_PACKED (t) = 0; cant_pack = 1;
} }
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;
...@@ -3038,6 +3039,9 @@ check_field_decls (tree t, tree *access_decls, ...@@ -3038,6 +3039,9 @@ check_field_decls (tree t, tree *access_decls,
" but does not override %<operator=(const %T&)%>", t); " but does not override %<operator=(const %T&)%>", t);
} }
/* If any of the fields couldn't be packed, unset TYPE_PACKED. */
if (cant_pack)
TYPE_PACKED (t) = 0;
/* Check anonymous struct/anonymous union fields. */ /* Check anonymous struct/anonymous union fields. */
finish_struct_anon (t); finish_struct_anon (t);
......
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