+2006-10-17 Lee Millward <lee.millward@codesourcery.com>
+
+ PR c++/27952
+ * cp-tree.h (xref_basetypes): Return bool instead of void.
+ * decl.c (xref_basetypes): Adjust definition. Return false
+ if the class bases are invalid.
+ * parser.c (cp_parser_class_head): Check the return value
+ from xref_basetypes.
+
2006-10-17 Mark Mitchell <mark@codesourcery.com>
PR c++/28261
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 void xref_basetypes (tree, tree);
+extern bool xref_basetypes (tree, tree);
extern tree start_enum (tree);
extern void finish_enum (tree);
extern void build_enumerator (tree, tree, 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. */
+ Non-NULL TREE_TYPE indicates virtual inheritance.
+
+ Returns true if the binfo heirarchy was successfully created,
+ false if an error was detected. */
-void
+bool
xref_basetypes (tree ref, tree base_list)
{
tree *basep;
tree igo_prev; /* Track Inheritance Graph Order. */
if (ref == error_mark_node)
- return;
+ return false;
/* The base of a derived class is private by default, all others are
public. */
CLASSTYPE_NON_AGGREGATE (ref) = 1;
if (TREE_CODE (ref) == UNION_TYPE)
- error ("derived union %qT invalid", ref);
+ {
+ error ("derived union %qT invalid", ref);
+ return false;
+ }
}
if (max_bases > 1)
{
if (TYPE_FOR_JAVA (ref))
- error ("Java class %qT cannot have multiple bases", ref);
+ {
+ error ("Java class %qT cannot have multiple bases", ref);
+ return false;
+ }
}
if (max_vbases)
CLASSTYPE_VBASECLASSES (ref) = VEC_alloc (tree, gc, max_vbases);
if (TYPE_FOR_JAVA (ref))
- error ("Java class %qT cannot have virtual bases", ref);
+ {
+ error ("Java class %qT cannot have virtual bases", ref);
+ return false;
+ }
}
for (igo_prev = binfo; base_list; base_list = TREE_CHAIN (base_list))
{
error ("base type %qT fails to be a struct or class type",
basetype);
- continue;
+ return false;
}
if (TYPE_FOR_JAVA (basetype) && (current_lang_depth () == 0))
error ("recursive type %qT undefined", basetype);
else
error ("duplicate base type %qT invalid", basetype);
- continue;
+ return false;
}
TYPE_MARKED_P (basetype) = 1;
else
break;
}
+
+ return true;
}
\f
bases = cp_parser_base_clause (parser);
/* Process the base classes. */
- xref_basetypes (type, bases);
+ if (!xref_basetypes (type, bases))
+ type = NULL_TREE;
done:
/* Leave the scope given by the nested-name-specifier. We will