aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/class.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r--gcc/cp/class.c67
1 files changed, 31 insertions, 36 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 84ecf77f958..06f8cbceb53 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. */
@@ -5084,6 +5076,9 @@ finish_struct_1 (tree t)
DECL_SORTED_FIELDS (TYPE_MAIN_DECL (t)) = field_vec;
}
+ /* Complain if one of the field types requires lower visibility. */
+ constrain_class_visibility (t);
+
/* Make the rtl for any new vtables we have created, and unmark
the base types we marked. */
finish_vtbls (t);