PR c++/9256
* pt.c (tsubst): Substitution must fail if we are attempting to
create an array with element type that is an abstract class type.
* decl.c (cp_finish_decl): Strip pointers and array types recursively
before calling abstract_virtuals_error.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@75618
138bc75d-0d04-0410-961f-
82ee72b054a4
+2004-01-10 Giovanni Bajo <giovannibajo@gcc.gnu.org>
+
+ DR 337
+ PR c++/9256
+ * pt.c (tsubst): Substitution must fail if we are attempting to
+ create an array with element type that is an abstract class type.
+ * decl.c (cp_finish_decl): Strip pointers and array types recursively
+ before calling abstract_virtuals_error.
+
2004-01-09 Alexandre Oliva <aoliva@redhat.com>
* name-lookup.c (qualified_lookup_using_namespace): Consider
|| TREE_CODE (type) == METHOD_TYPE)
abstract_virtuals_error (decl,
strip_array_types (TREE_TYPE (type)));
+ else if (POINTER_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE)
+ {
+ /* If it's either a pointer or an array type, strip through all
+ of them but the last one. If the last is an array type, issue
+ an error if the element type is abstract. */
+ while (POINTER_TYPE_P (TREE_TYPE (type))
+ || TREE_CODE (TREE_TYPE (type)) == ARRAY_TYPE)
+ type = TREE_TYPE (type);
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ abstract_virtuals_error (decl, TREE_TYPE (type));
+ }
else
- abstract_virtuals_error (decl, strip_array_types (type));
+ abstract_virtuals_error (decl, type);
if (TREE_CODE (decl) == FUNCTION_DECL
|| TREE_TYPE (decl) == error_mark_node)
The deduction may fail for any of the following reasons:
-- Attempting to create an array with an element type that
- is void, a function type, or a reference type. */
+ is void, a function type, or a reference type, or [DR337]
+ an abstract class type. */
if (TREE_CODE (type) == VOID_TYPE
|| TREE_CODE (type) == FUNCTION_TYPE
|| TREE_CODE (type) == REFERENCE_TYPE)
error ("creating array of `%T'", type);
return error_mark_node;
}
+ if (CLASS_TYPE_P (type) && CLASSTYPE_PURE_VIRTUALS (type))
+ {
+ if (complain & tf_error)
+ error ("creating array of `%T', which is an abstract class type",
+ type);
+ return error_mark_node;
+ }
r = build_cplus_array_type (type, domain);
return r;