mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-23 10:39:40 +08:00
DR 337 PR c++/9256
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. From-SVN: r75618
This commit is contained in:
parent
f88e471576
commit
cfb91b67b8
@ -1,3 +1,12 @@
|
|||||||
|
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>
|
2004-01-09 Alexandre Oliva <aoliva@redhat.com>
|
||||||
|
|
||||||
* name-lookup.c (qualified_lookup_using_namespace): Consider
|
* name-lookup.c (qualified_lookup_using_namespace): Consider
|
||||||
|
@ -4879,8 +4879,19 @@ cp_finish_decl (tree decl, tree init, tree asmspec_tree, int flags)
|
|||||||
|| TREE_CODE (type) == METHOD_TYPE)
|
|| TREE_CODE (type) == METHOD_TYPE)
|
||||||
abstract_virtuals_error (decl,
|
abstract_virtuals_error (decl,
|
||||||
strip_array_types (TREE_TYPE (type)));
|
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
|
else
|
||||||
abstract_virtuals_error (decl, strip_array_types (type));
|
abstract_virtuals_error (decl, type);
|
||||||
|
|
||||||
if (TREE_CODE (decl) == FUNCTION_DECL
|
if (TREE_CODE (decl) == FUNCTION_DECL
|
||||||
|| TREE_TYPE (decl) == error_mark_node)
|
|| TREE_TYPE (decl) == error_mark_node)
|
||||||
|
10
gcc/cp/pt.c
10
gcc/cp/pt.c
@ -6975,7 +6975,8 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
|
|||||||
The deduction may fail for any of the following reasons:
|
The deduction may fail for any of the following reasons:
|
||||||
|
|
||||||
-- Attempting to create an array with an element type that
|
-- 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
|
if (TREE_CODE (type) == VOID_TYPE
|
||||||
|| TREE_CODE (type) == FUNCTION_TYPE
|
|| TREE_CODE (type) == FUNCTION_TYPE
|
||||||
|| TREE_CODE (type) == REFERENCE_TYPE)
|
|| TREE_CODE (type) == REFERENCE_TYPE)
|
||||||
@ -6984,6 +6985,13 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl)
|
|||||||
error ("creating array of `%T'", type);
|
error ("creating array of `%T'", type);
|
||||||
return error_mark_node;
|
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);
|
r = build_cplus_array_type (type, domain);
|
||||||
return r;
|
return r;
|
||||||
|
Loading…
Reference in New Issue
Block a user