aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2006-08-30 11:51:17 -0400
committerJason Merrill <jason@gcc.gnu.org>2006-08-30 11:51:17 -0400
commit220020507605be7dd81ade8adbfe866b2005faf9 (patch)
tree0926b7c0d5b0b0d69cc44d712e7f204ca9ee991b
parent884f22e3a20aed205be7c50624361b8f9c7babd0 (diff)
downloadgcc-220020507605be7dd81ade8adbfe866b2005faf9.zip
gcc-220020507605be7dd81ade8adbfe866b2005faf9.tar.gz
gcc-220020507605be7dd81ade8adbfe866b2005faf9.tar.bz2
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
-rw-r--r--gcc/cp/ChangeLog6
-rw-r--r--gcc/cp/class.c16
2 files changed, 16 insertions, 6 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index cda2742..5311778 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+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>
PR C++/28349
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 550edff..7361b5a 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -2795,6 +2795,7 @@ check_field_decls (tree t, tree *access_decls,
tree *next;
bool has_pointers;
int any_default_members;
+ int cant_pack = 0;
/* Assume there are no access declarations. */
*access_decls = NULL_TREE;
@@ -2911,7 +2912,7 @@ check_field_decls (tree t, tree *access_decls,
(0,
"ignoring packed attribute because of unpacked non-POD field %q+#D",
x);
- TYPE_PACKED (t) = 0;
+ cant_pack = 1;
}
else if (TYPE_ALIGN (TREE_TYPE (x)) > BITS_PER_UNIT)
DECL_PACKED (x) = 1;
@@ -3018,11 +3019,11 @@ check_field_decls (tree t, tree *access_decls,
is needed to free dynamic memory.
This seems enough for practical purposes. */
- if (warn_ecpp
- && has_pointers
- && TYPE_HAS_CONSTRUCTOR (t)
- && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)
- && !(TYPE_HAS_INIT_REF (t) && TYPE_HAS_ASSIGN_REF (t)))
+ if (warn_ecpp
+ && has_pointers
+ && TYPE_HAS_CONSTRUCTOR (t)
+ && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)
+ && !(TYPE_HAS_INIT_REF (t) && TYPE_HAS_ASSIGN_REF (t)))
{
warning (OPT_Weffc__, "%q#T has pointer data members", t);
@@ -3038,6 +3039,9 @@ check_field_decls (tree t, tree *access_decls,
" 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. */
finish_struct_anon (t);