Commit 8c90d611 by Jason Merrill

call.c (build_method_call): Make sure get_type_value returns something before we try to use its...

	* call.c (build_method_call): Make sure get_type_value returns
	something before we try to use its TYPE_MAIN_VARIANT.
	* typeck2.c (digest_init): Complain about getting a TREE_LIST to
	initialize an array.
	* search.c (expand_upcast_fixups): Don't set DECL_CONTEXT and
	DECL_VIRTUAL_P.

From-SVN: r20110
parent ca379c1c
1998-05-27 Brendan Kehoe <brendan@cygnus.com>
* call.c (build_method_call): Make sure get_type_value returns
something before we try to use its TYPE_MAIN_VARIANT.
1998-05-27 Jason Merrill <jason@yorick.cygnus.com>
* typeck2.c (digest_init): Complain about getting a TREE_LIST to
initialize an array.
* search.c (expand_upcast_fixups): Don't set DECL_CONTEXT and
DECL_VIRTUAL_P.
* friend.c (do_friend): Clarify template warning.
1998-05-27 Mark Mitchell <mark@markmitchell.com>
......
......@@ -632,6 +632,7 @@ build_method_call (instance, name, parms, basetype_path, flags)
if (TREE_CODE (name) == BIT_NOT_EXPR)
{
tree tmp;
flags |= LOOKUP_DESTRUCTOR;
name = TREE_OPERAND (name, 0);
if (parms)
......@@ -642,8 +643,9 @@ build_method_call (instance, name, parms, basetype_path, flags)
if (! (name == TYPE_MAIN_VARIANT (basetype)
|| (IS_AGGR_TYPE (basetype)
&& name == constructor_name (basetype))
|| (TYPE_MAIN_VARIANT (basetype)
== TYPE_MAIN_VARIANT (get_type_value (name)))))
|| ((tmp = get_type_value (name))
&& (TYPE_MAIN_VARIANT (basetype)
== TYPE_MAIN_VARIANT (tmp)))))
{
cp_error ("destructor name `~%D' does not match type `%T' of expression",
name, basetype);
......
......@@ -2918,32 +2918,43 @@ expand_upcast_fixups (binfo, addr, orig_addr, vbase, vbase_addr, t,
|| nvtbl == IDENTIFIER_GLOBAL_VALUE (DECL_NAME (vtbl)))
{
/* Dup it if it isn't in local scope yet. */
nvtbl = build_decl (VAR_DECL,
DECL_NAME (vtbl),
TYPE_MAIN_VARIANT (TREE_TYPE (BINFO_VTABLE (binfo))));
nvtbl = build_decl
(VAR_DECL, DECL_NAME (vtbl),
TYPE_MAIN_VARIANT (TREE_TYPE (BINFO_VTABLE (binfo))));
DECL_ALIGN (nvtbl) = MAX (TYPE_ALIGN (double_type_node),
DECL_ALIGN (nvtbl));
TREE_READONLY (nvtbl) = 0;
DECL_ARTIFICIAL (nvtbl) = 1;
nvtbl = pushdecl (nvtbl);
init = NULL_TREE;
cp_finish_decl (nvtbl, init, NULL_TREE, 0, LOOKUP_ONLYCONVERTING);
DECL_VIRTUAL_P (nvtbl) = 1;
DECL_CONTEXT (nvtbl) = t;
cp_finish_decl (nvtbl, init, NULL_TREE, 0,
LOOKUP_ONLYCONVERTING);
/* We don't set DECL_VIRTUAL_P and DECL_CONTEXT on nvtbl
because they wouldn't be useful; everything that wants to
look at the vtable will look at the decl for the normal
vtable. Setting DECL_CONTEXT also screws up
decl_function_context. */
init = build (MODIFY_EXPR, TREE_TYPE (nvtbl),
nvtbl, vtbl);
TREE_SIDE_EFFECTS (init) = 1;
expand_expr_stmt (init);
/* Update the vtable pointers as necessary. */
ref = build_vfield_ref (build_indirect_ref (addr, NULL_PTR), DECL_CONTEXT (CLASSTYPE_VFIELD (BINFO_TYPE (binfo))));
expand_expr_stmt (build_modify_expr (ref, NOP_EXPR,
build_unary_op (ADDR_EXPR, nvtbl, 0)));
ref = build_vfield_ref
(build_indirect_ref (addr, NULL_PTR),
DECL_CONTEXT (CLASSTYPE_VFIELD (BINFO_TYPE (binfo))));
expand_expr_stmt
(build_modify_expr (ref, NOP_EXPR,
build_unary_op (ADDR_EXPR, nvtbl, 0)));
}
assemble_external (vtbl);
aref = build_array_ref (vtbl, idx);
naref = build_array_ref (nvtbl, idx);
old_delta = build_component_ref (aref, delta_identifier, NULL_TREE, 0);
new_delta = build_component_ref (naref, delta_identifier, NULL_TREE, 0);
old_delta = build_component_ref (aref, delta_identifier,
NULL_TREE, 0);
new_delta = build_component_ref (naref, delta_identifier,
NULL_TREE, 0);
/* This is a upcast, so we have to add the offset for the
virtual base. */
......
......@@ -781,7 +781,15 @@ digest_init (type, init, tail)
if (code == ARRAY_TYPE)
{
tree typ1 = TYPE_MAIN_VARIANT (TREE_TYPE (type));
tree typ1;
if (TREE_CODE (init) == TREE_LIST)
{
error ("initializing array with parameter list");
return error_mark_node;
}
typ1 = TYPE_MAIN_VARIANT (TREE_TYPE (type));
if ((typ1 == char_type_node
|| typ1 == signed_char_type_node
|| typ1 == unsigned_char_type_node
......
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