diff options
author | obrien <obrien@FreeBSD.org> | 2002-12-04 15:42:16 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2002-12-04 15:42:16 +0000 |
commit | 7a1080fa5c329ea8a9505e51ce151719955bcfa2 (patch) | |
tree | 78b77287e56e2a87be73638176124be85a8fc6c7 /contrib/gcc/cp/class.c | |
parent | ef3bb1318428b8cfb1c8287f61b9b1f23f9bf0b5 (diff) | |
download | FreeBSD-src-7a1080fa5c329ea8a9505e51ce151719955bcfa2.zip FreeBSD-src-7a1080fa5c329ea8a9505e51ce151719955bcfa2.tar.gz |
Gcc 3.2.1 release virgin vendor import. (19-Nov-2002)
Diffstat (limited to 'contrib/gcc/cp/class.c')
-rw-r--r-- | contrib/gcc/cp/class.c | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/contrib/gcc/cp/class.c b/contrib/gcc/cp/class.c index 2395d79..2ac4e30 100644 --- a/contrib/gcc/cp/class.c +++ b/contrib/gcc/cp/class.c @@ -945,6 +945,13 @@ add_method (type, method, error_p) && (TYPE_QUALS (TREE_TYPE (TREE_VALUE (parms1))) != TYPE_QUALS (TREE_TYPE (TREE_VALUE (parms2))))) same = 0; + + /* For templates, the template parms must be identical. */ + if (TREE_CODE (fn) == TEMPLATE_DECL + && !comp_template_parms (DECL_TEMPLATE_PARMS (fn), + DECL_TEMPLATE_PARMS (method))) + same = 0; + if (! DECL_STATIC_FUNCTION_P (fn)) parms1 = TREE_CHAIN (parms1); if (! DECL_STATIC_FUNCTION_P (method)) @@ -1150,9 +1157,12 @@ handle_using_decl (using_decl, t) tree flist = NULL_TREE; tree old_value; - binfo = binfo_or_else (ctype, t); + binfo = lookup_base (t, ctype, ba_any, NULL); if (! binfo) - return; + { + error_not_base_type (t, ctype); + return; + } if (name == constructor_name (ctype) || name == constructor_name_full (ctype)) @@ -1338,6 +1348,8 @@ check_bases (t, cant_have_default_ctor_p, cant_have_const_ctor_p, TYPE_OVERLOADS_ARRAY_REF (t) |= TYPE_OVERLOADS_ARRAY_REF (basetype); TYPE_OVERLOADS_ARROW (t) |= TYPE_OVERLOADS_ARROW (basetype); TYPE_POLYMORPHIC_P (t) |= TYPE_POLYMORPHIC_P (basetype); + CLASSTYPE_CONTAINS_EMPTY_CLASS_P (t) + |= CLASSTYPE_CONTAINS_EMPTY_CLASS_P (basetype); } } @@ -3237,10 +3249,18 @@ check_field_decls (t, access_decls, empty_p, ; else { + tree element_type; + /* The class is non-empty. */ *empty_p = 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; } } @@ -3322,7 +3342,7 @@ check_field_decls (t, access_decls, empty_p, { CLASSTYPE_NON_POD_P (t) = 1; if (DECL_INITIAL (x) == NULL_TREE) - CLASSTYPE_REF_FIELDS_NEED_INIT (t) = 1; + SET_CLASSTYPE_REF_FIELDS_NEED_INIT (t, 1); /* ARM $12.6.2: [A member initializer list] (or, for an aggregate, initialization by a brace-enclosed list) is the @@ -3356,7 +3376,7 @@ check_field_decls (t, access_decls, empty_p, { C_TYPE_FIELDS_READONLY (t) = 1; if (DECL_INITIAL (x) == NULL_TREE) - CLASSTYPE_READONLY_FIELDS_NEED_INIT (t) = 1; + SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT (t, 1); /* ARM $12.6.2: [A member initializer list] (or, for an aggregate, initialization by a brace-enclosed list) is the @@ -3372,8 +3392,9 @@ check_field_decls (t, access_decls, empty_p, else if (IS_AGGR_TYPE (type)) { C_TYPE_FIELDS_READONLY (t) |= C_TYPE_FIELDS_READONLY (type); - CLASSTYPE_READONLY_FIELDS_NEED_INIT (t) - |= CLASSTYPE_READONLY_FIELDS_NEED_INIT (type); + SET_CLASSTYPE_READONLY_FIELDS_NEED_INIT (t, + CLASSTYPE_READONLY_FIELDS_NEED_INIT (t) + | CLASSTYPE_READONLY_FIELDS_NEED_INIT (type)); } /* Core issue 80: A nonstatic data member is required to have a @@ -3507,6 +3528,10 @@ walk_subobject_offsets (type, f, offset, offsets, max_offset, vbases_p) tree field; int i; + /* Avoid recursing into objects that are not interesting. */ + if (!CLASSTYPE_CONTAINS_EMPTY_CLASS_P (type)) + return 0; + /* Record the location of TYPE. */ r = (*f) (type, offset, offsets); if (r) @@ -3552,9 +3577,15 @@ walk_subobject_offsets (type, f, offset, offsets, max_offset, vbases_p) } else if (TREE_CODE (type) == ARRAY_TYPE) { + tree element_type = strip_array_types (type); tree domain = TYPE_DOMAIN (type); tree index; + /* Avoid recursing into objects that are not interesting. */ + if (!CLASS_TYPE_P (element_type) + || !CLASSTYPE_CONTAINS_EMPTY_CLASS_P (element_type)) + return 0; + /* Step through each of the elements in the array. */ for (index = size_zero_node; INT_CST_LT (index, TYPE_MAX_VALUE (domain)); @@ -4267,6 +4298,7 @@ check_bases_and_members (t, empty_p) /* Assume that the class is nearly empty; we'll clear this flag if it turns out not to be nearly empty. */ CLASSTYPE_NEARLY_EMPTY_P (t) = 1; + CLASSTYPE_CONTAINS_EMPTY_CLASS_P (t) = 0; /* Check all the base-classes. */ check_bases (t, &cant_have_default_ctor, &cant_have_const_ctor, @@ -4974,6 +5006,10 @@ layout_class_type (t, empty_p, vfuns_p, virtuals_p) CLASSTYPE_ALIGN (t) = TYPE_ALIGN (t); CLASSTYPE_USER_ALIGN (t) = TYPE_USER_ALIGN (t); + /* Every empty class contains an empty class. */ + if (*empty_p) + CLASSTYPE_CONTAINS_EMPTY_CLASS_P (t) = 1; + /* Set the TYPE_DECL for this type to contain the right value for DECL_OFFSET, so that we can use it as part of a COMPONENT_REF for multiple inheritance. */ |