Commit 3fd71a52 by Mark Mitchell Committed by Mark Mitchell

decl.c (xref_basetypes): Comment.

	* decl.c (xref_basetypes): Comment.
	* pt.c (instantiate_class_template): Use xref_basetypes.

From-SVN: r25272
parent 176c720e
1999-02-17 Mark Mitchell <mark@markmitchell.com>
* decl.c (xref_basetypes): Comment.
* pt.c (instantiate_class_template): Use xref_basetypes.
1999-02-16 Mark Mitchell <mark@markmitchell.com> 1999-02-16 Mark Mitchell <mark@markmitchell.com>
* cp-tree.h (tsubst): Change prototype. * cp-tree.h (tsubst): Change prototype.
......
...@@ -12357,6 +12357,12 @@ xref_tag_from_type (old, id, globalize) ...@@ -12357,6 +12357,12 @@ xref_tag_from_type (old, id, globalize)
return xref_tag (code_type_node, id, globalize); return xref_tag (code_type_node, id, globalize);
} }
/* REF is a type (named NAME), for which we have just seen some
baseclasses. BINFO is a list of those baseclasses; the
TREE_PURPOSE is an access_* node, and the TREE_VALUE is the type of
the base-class. CODE_TYPE_NODE indicates whether REF is a class,
struct, or union. */
void void
xref_basetypes (code_type_node, name, ref, binfo) xref_basetypes (code_type_node, name, ref, binfo)
tree code_type_node; tree code_type_node;
......
...@@ -4688,53 +4688,64 @@ instantiate_class_template (type) ...@@ -4688,53 +4688,64 @@ instantiate_class_template (type)
DECL_TI_ARGS of some instantiated member template. */ DECL_TI_ARGS of some instantiated member template. */
args = copy_to_permanent (args); args = copy_to_permanent (args);
{ if (TYPE_BINFO_BASETYPES (pattern))
tree binfo = TYPE_BINFO (type); {
tree pbases = TYPE_BINFO_BASETYPES (pattern); tree base_list = NULL_TREE;
tree pbases = TYPE_BINFO_BASETYPES (pattern);
int i;
if (pbases) /* Substitute into each of the bases to determine the actual
{ basetypes. */
tree bases; for (i = 0; i < TREE_VEC_LENGTH (pbases); ++i)
int i; {
int len = TREE_VEC_LENGTH (pbases); tree base;
bases = make_tree_vec (len); tree access;
for (i = 0; i < len; ++i) tree pbase;
{
tree elt, basetype;
TREE_VEC_ELT (bases, i) = elt pbase = TREE_VEC_ELT (pbases, i);
= tsubst (TREE_VEC_ELT (pbases, i), args,
/*complain=*/1, NULL_TREE);
BINFO_INHERITANCE_CHAIN (elt) = binfo;
basetype = TREE_TYPE (elt); /* Substitue to figure out the base class. */
base = tsubst (BINFO_TYPE (pbase), args,
/*complain=*/1, NULL_TREE);
if (base == error_mark_node)
continue;
if (! IS_AGGR_TYPE (basetype)) /* Calculate the correct access node. */
cp_error if (TREE_VIA_VIRTUAL (pbase))
("base type `%T' of `%T' fails to be a struct or class type", {
basetype, type); if (TREE_VIA_PUBLIC (pbase))
else if (TYPE_SIZE (complete_type (basetype)) == NULL_TREE) access = access_public_virtual_node;
cp_error ("base class `%T' of `%T' has incomplete type", else if (TREE_VIA_PROTECTED (pbase))
basetype, type); access = access_protected_virtual_node;
else if (TREE_VIA_PRIVATE (pbase))
access = access_private_virtual_node;
}
else
{
if (TREE_VIA_PUBLIC (pbase))
access = access_public_node;
else if (TREE_VIA_PROTECTED (pbase))
access = access_protected_node;
else if (TREE_VIA_PRIVATE (pbase))
access = access_private_node;
}
/* These are set up in xref_basetypes for normal classes, so base_list = tree_cons (access, base, base_list);
we have to handle them here for template bases. */ }
unshare_base_binfos (elt); /* The list is now in reverse order; correct that. */
base_list = nreverse (base_list);
if (TYPE_USES_VIRTUAL_BASECLASSES (basetype)) /* Now call xref_basetypes to set up all the base-class
{ information. */
TYPE_USES_VIRTUAL_BASECLASSES (type) = 1; xref_basetypes (TREE_CODE (pattern) == RECORD_TYPE
TYPE_USES_COMPLEX_INHERITANCE (type) = 1; ? (CLASSTYPE_DECLARED_CLASS (pattern)
} ? class_type_node : record_type_node)
TYPE_GETS_NEW (type) |= TYPE_GETS_NEW (basetype); : union_type_node,
TYPE_GETS_DELETE (type) |= TYPE_GETS_DELETE (basetype); DECL_NAME (TYPE_NAME (pattern)),
} type,
/* Don't initialize this until the vector is filled out, or base_list);
lookups will crash. */ }
BINFO_BASETYPES (binfo) = bases;
}
}
for (t = CLASSTYPE_TAGS (pattern); t; t = TREE_CHAIN (t)) for (t = CLASSTYPE_TAGS (pattern); t; t = TREE_CHAIN (t))
{ {
......
// Origin: Wolfgang Bangerth <wolf@gaia.iwr.uni-heidelberg.de>
int i = 1;
struct Base1 { int local1; };
struct Base2 { int local2; };
template <int dim> class Derived;
template <>
class Derived<1> : public Base1, public Base2 {};
template <int dim>
class FinalClass : public Derived<dim> {
public:
FinalClass () {
if (&local1 != &local2)
i = 0;
}
};
int main () {
FinalClass<1> a1;
return i;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment