From 37a247a0a0fdbe1450ce2284b12b8e7f6c304909 Mon Sep 17 00:00:00 2001 From: Nathan Sidwell Date: Thu, 15 Jul 2004 08:33:27 +0000 Subject: [PATCH] class.c (check_bases): Don't set CLASSTYPE_NON_AGGREGATE here. * class.c (check_bases): Don't set CLASSTYPE_NON_AGGREGATE here. Don't check for incomplete base. (get_vfield_name): Simplify while loop. * decl.c (xref_basetypes): Set CLASSTYPE_NON_AGGREGATE here. From-SVN: r84747 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/class.c | 39 +++++++++++++-------------------------- gcc/cp/decl.c | 6 +++++- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index f95168a408f..703941bad9b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +2004-07-15 Nathan Sidwell + + * class.c (check_bases): Don't set CLASSTYPE_NON_AGGREGATE here. + Don't check for incomplete base. + (get_vfield_name): Simplify while loop. + * decl.c (xref_basetypes): Set CLASSTYPE_NON_AGGREGATE here. + 2004-07-14 Mark Mitchell * lex.c (cxx_make_type): Remove call to get_pointer_type. diff --git a/gcc/cp/class.c b/gcc/cp/class.c index b292255fd13..de1aadded39 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1198,9 +1198,6 @@ check_bases (tree t, n_baseclasses = BINFO_N_BASE_BINFOS (TYPE_BINFO (t)); seen_non_virtual_nearly_empty_base_p = 0; - /* An aggregate cannot have baseclasses. */ - CLASSTYPE_NON_AGGREGATE (t) |= (n_baseclasses != 0); - for (i = 0; i < n_baseclasses; ++i) { tree base_binfo; @@ -1210,24 +1207,8 @@ check_bases (tree t, base_binfo = TREE_VEC_ELT (binfos, i); basetype = TREE_TYPE (base_binfo); - /* If the type of basetype is incomplete, then we already - complained about that fact (and we should have fixed it up as - well). */ - if (!COMPLETE_TYPE_P (basetype)) - { - int j; - /* The base type is of incomplete type. It is - probably best to pretend that it does not - exist. */ - if (i == n_baseclasses-1) - TREE_VEC_ELT (binfos, i) = NULL_TREE; - TREE_VEC_LENGTH (binfos) -= 1; - n_baseclasses -= 1; - for (j = i; j+1 < n_baseclasses; j++) - TREE_VEC_ELT (binfos, j) = TREE_VEC_ELT (binfos, j+1); - continue; - } - + my_friendly_assert (COMPLETE_TYPE_P (basetype), 20040714); + /* Effective C++ rule 14. We only need to check TYPE_POLYMORPHIC_P here because the case of virtual functions but non-virtual dtor is handled in finish_struct_1. */ @@ -6260,14 +6241,20 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t flags) static tree get_vfield_name (tree type) { - tree binfo = TYPE_BINFO (type); + tree binfo, base_binfo; char *buf; - while (BINFO_BASE_BINFOS (binfo) - && TYPE_CONTAINS_VPTR_P (BINFO_TYPE (BINFO_BASE_BINFO (binfo, 0))) - && ! BINFO_VIRTUAL_P (BINFO_BASE_BINFO (binfo, 0))) - binfo = BINFO_BASE_BINFO (binfo, 0); + for (binfo = TYPE_BINFO (type); + BINFO_BASE_BINFOS (binfo); + binfo = base_binfo) + { + base_binfo = BINFO_BASE_BINFO (binfo, 0); + if (BINFO_VIRTUAL_P (base_binfo) + || !TYPE_CONTAINS_VPTR_P (BINFO_TYPE (base_binfo))) + break; + } + type = BINFO_TYPE (binfo); buf = alloca (sizeof (VFIELD_NAME_FORMAT) + TYPE_NAME_LENGTH (type) + 2); sprintf (buf, VFIELD_NAME_FORMAT, diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 727734347d2..d91709ea45d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -9176,7 +9176,11 @@ xref_basetypes (tree ref, tree base_list) i++; } if (i) - TREE_VEC_LENGTH (accesses) = TREE_VEC_LENGTH (binfos) = i; + { + TREE_VEC_LENGTH (accesses) = TREE_VEC_LENGTH (binfos) = i; + /* An aggregate cannot have baseclasses. */ + CLASSTYPE_NON_AGGREGATE (ref) = 1; + } else BINFO_BASE_ACCESSES (binfo) = BINFO_BASE_BINFOS (binfo) = NULL_TREE; if (max_vbases) -- 2.30.2