diff options
author | Jason Merrill <jason@redhat.com> | 2006-07-05 22:09:02 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2006-07-05 22:09:02 -0400 |
commit | 1937f93932b3249756fbeda05a0b0c67aaed0405 (patch) | |
tree | e5a04b6dd5dab15766d0b02b4b48425818534909 /gcc/cp/class.c | |
parent | 562349cab017b2abc827517378ac50a1f4a1f438 (diff) | |
download | gcc-1937f93932b3249756fbeda05a0b0c67aaed0405.zip gcc-1937f93932b3249756fbeda05a0b0c67aaed0405.tar.gz gcc-1937f93932b3249756fbeda05a0b0c67aaed0405.tar.bz2 |
re PR c++/13983 (no warning on some non-POD struct with packed attribute)
PR c++/13983
PR c++/17519
* stor-layout.c (finish_record_layout): Copy TYPE_PACKED to variants.
* c-common.c (handle_packed_attribute): So don't copy it here.
* c-decl.c (finish_struct): Don't copy TYPE_ALIGN.
* cp/class.c (check_field_decls): Check TYPE_PACKED after
stripping array types.
(finish_struct_bits): Don't copy TYPE_SIZE here.
From-SVN: r115217
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 64 |
1 files changed, 28 insertions, 36 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 9761c5c..06f8cbc 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1433,8 +1433,6 @@ finish_struct_bits (tree t) TYPE_VFIELD (variants) = TYPE_VFIELD (t); TYPE_METHODS (variants) = TYPE_METHODS (t); TYPE_FIELDS (variants) = TYPE_FIELDS (t); - TYPE_SIZE (variants) = TYPE_SIZE (t); - TYPE_SIZE_UNIT (variants) = TYPE_SIZE_UNIT (t); } if (BINFO_N_BASE_BINFOS (TYPE_BINFO (t)) && TYPE_POLYMORPHIC_P (t)) @@ -2815,40 +2813,6 @@ check_field_decls (tree t, tree *access_decls, next = &TREE_CHAIN (x); - if (TREE_CODE (x) == FIELD_DECL) - { - if (TYPE_PACKED (t)) - { - if (!pod_type_p (TREE_TYPE (x)) && !TYPE_PACKED (TREE_TYPE (x))) - warning - (0, - "ignoring packed attribute on unpacked non-POD field %q+#D", - x); - else if (TYPE_ALIGN (TREE_TYPE (x)) > BITS_PER_UNIT) - DECL_PACKED (x) = 1; - } - - if (DECL_C_BIT_FIELD (x) && integer_zerop (DECL_INITIAL (x))) - /* We don't treat zero-width bitfields as making a class - non-empty. */ - ; - else - { - tree element_type; - - /* The class is non-empty. */ - CLASSTYPE_EMPTY_P (t) = 0; - /* The class is not even nearly empty. */ - CLASSTYPE_NEARLY_EMPTY_P (t) = 0; - /* If one of the data members contains an empty class, - so does T. */ - element_type = strip_array_types (type); - if (CLASS_TYPE_P (element_type) - && CLASSTYPE_CONTAINS_EMPTY_CLASS_P (element_type)) - CLASSTYPE_CONTAINS_EMPTY_CLASS_P (t) = 1; - } - } - if (TREE_CODE (x) == USING_DECL) { /* Prune the access declaration from the list of fields. */ @@ -2945,6 +2909,34 @@ check_field_decls (tree t, tree *access_decls, type = strip_array_types (type); + 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); + else if (TYPE_ALIGN (TREE_TYPE (x)) > BITS_PER_UNIT) + DECL_PACKED (x) = 1; + } + + if (DECL_C_BIT_FIELD (x) && integer_zerop (DECL_INITIAL (x))) + /* We don't treat zero-width bitfields as making a class + non-empty. */ + ; + else + { + /* The class is non-empty. */ + CLASSTYPE_EMPTY_P (t) = 0; + /* The class is not even nearly empty. */ + CLASSTYPE_NEARLY_EMPTY_P (t) = 0; + /* If one of the data members contains an empty class, + so does T. */ + if (CLASS_TYPE_P (type) + && CLASSTYPE_CONTAINS_EMPTY_CLASS_P (type)) + CLASSTYPE_CONTAINS_EMPTY_CLASS_P (t) = 1; + } + /* This is used by -Weffc++ (see below). Warn only for pointers to members which might hold dynamic memory. So do not warn for pointers to functions or pointers to members. */ |