extern bool grok_op_properties (tree, bool);
extern tree xref_tag (enum tag_types, tree, tag_scope, bool);
extern tree xref_tag_from_type (tree, tree, tag_scope);
-extern bool xref_basetypes (tree, tree);
+extern void xref_basetypes (tree, tree);
extern tree start_enum (tree, tree, tree, tree, bool, bool *);
extern void finish_enum_value_list (tree);
extern void finish_enum (tree);
/* Create the binfo hierarchy for REF with (possibly NULL) base list
BASE_LIST. For each element on BASE_LIST the TREE_PURPOSE is an
access_* node, and the TREE_VALUE is the type of the base-class.
- Non-NULL TREE_TYPE indicates virtual inheritance.
-
- Returns true if the binfo hierarchy was successfully created,
- false if an error was detected. */
+ Non-NULL TREE_TYPE indicates virtual inheritance. */
-bool
+void
xref_basetypes (tree ref, tree base_list)
{
tree *basep;
tree igo_prev; /* Track Inheritance Graph Order. */
if (ref == error_mark_node)
- return false;
+ return;
/* The base of a derived class is private by default, all others are
public. */
/* The binfo slot should be empty, unless this is an (ill-formed)
redefinition. */
- if (TYPE_BINFO (ref) && !TYPE_SIZE (ref))
- {
- error ("redefinition of %q#T", ref);
- return false;
- }
+ gcc_assert (!TYPE_BINFO (ref) || TYPE_SIZE (ref));
gcc_assert (TYPE_MAIN_VARIANT (ref) == ref);
CLASSTYPE_NON_AGGREGATE (ref) = 1;
if (TREE_CODE (ref) == UNION_TYPE)
- {
- error ("derived union %qT invalid", ref);
- return false;
- }
+ error ("derived union %qT invalid", ref);
}
if (max_bases > 1)
{
if (TYPE_FOR_JAVA (ref))
- {
- error ("Java class %qT cannot have multiple bases", ref);
- return false;
- }
+ error ("Java class %qT cannot have multiple bases", ref);
else
warning (OPT_Wmultiple_inheritance,
"%qT defined with multiple direct bases", ref);
vec_alloc (CLASSTYPE_VBASECLASSES (ref), max_vbases);
if (TYPE_FOR_JAVA (ref))
- {
- error ("Java class %qT cannot have virtual bases", ref);
- return false;
- }
+ error ("Java class %qT cannot have virtual bases", ref);
else if (max_dvbases)
warning (OPT_Wvirtual_inheritance,
"%qT defined with direct virtual base", ref);
{
error ("base type %qT fails to be a struct or class type",
basetype);
- return false;
+ goto dropped_base;
}
if (TYPE_FOR_JAVA (basetype) && (current_lang_depth () == 0))
error ("recursive type %qT undefined", basetype);
else
error ("duplicate base type %qT invalid", basetype);
- return false;
+ goto dropped_base;
}
if (PACK_EXPANSION_P (TREE_VALUE (base_list)))
BINFO_BASE_APPEND (binfo, base_binfo);
BINFO_BASE_ACCESS_APPEND (binfo, access);
+ continue;
+
+ dropped_base:
+ /* Update max_vbases to reflect the reality that we are dropping
+ this base: if it reaches zero we want to undo the vec_alloc
+ above to avoid inconsistencies during error-recovery: eg, in
+ build_special_member_call, CLASSTYPE_VBASECLASSES non null
+ and vtt null (c++/27952). */
+ if (via_virtual)
+ max_vbases--;
+ if (CLASS_TYPE_P (basetype))
+ max_vbases
+ -= vec_safe_length (CLASSTYPE_VBASECLASSES (basetype));
}
+ if (CLASSTYPE_VBASECLASSES (ref)
+ && max_vbases == 0)
+ vec_free (CLASSTYPE_VBASECLASSES (ref));
+
if (vec_safe_length (CLASSTYPE_VBASECLASSES (ref)) < max_vbases)
/* If we didn't get max_vbases vbases, we must have shared at
least one of them, and are therefore diamond shaped. */
else
break;
}
-
- return true;
}
\f