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> 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. * friend.c (do_friend): Clarify template warning.
1998-05-27 Mark Mitchell <mark@markmitchell.com> 1998-05-27 Mark Mitchell <mark@markmitchell.com>
......
...@@ -632,6 +632,7 @@ build_method_call (instance, name, parms, basetype_path, flags) ...@@ -632,6 +632,7 @@ build_method_call (instance, name, parms, basetype_path, flags)
if (TREE_CODE (name) == BIT_NOT_EXPR) if (TREE_CODE (name) == BIT_NOT_EXPR)
{ {
tree tmp;
flags |= LOOKUP_DESTRUCTOR; flags |= LOOKUP_DESTRUCTOR;
name = TREE_OPERAND (name, 0); name = TREE_OPERAND (name, 0);
if (parms) if (parms)
...@@ -642,8 +643,9 @@ build_method_call (instance, name, parms, basetype_path, flags) ...@@ -642,8 +643,9 @@ build_method_call (instance, name, parms, basetype_path, flags)
if (! (name == TYPE_MAIN_VARIANT (basetype) if (! (name == TYPE_MAIN_VARIANT (basetype)
|| (IS_AGGR_TYPE (basetype) || (IS_AGGR_TYPE (basetype)
&& name == constructor_name (basetype)) && name == constructor_name (basetype))
|| (TYPE_MAIN_VARIANT (basetype) || ((tmp = get_type_value (name))
== TYPE_MAIN_VARIANT (get_type_value (name))))) && (TYPE_MAIN_VARIANT (basetype)
== TYPE_MAIN_VARIANT (tmp)))))
{ {
cp_error ("destructor name `~%D' does not match type `%T' of expression", cp_error ("destructor name `~%D' does not match type `%T' of expression",
name, basetype); name, basetype);
......
...@@ -2918,32 +2918,43 @@ expand_upcast_fixups (binfo, addr, orig_addr, vbase, vbase_addr, t, ...@@ -2918,32 +2918,43 @@ expand_upcast_fixups (binfo, addr, orig_addr, vbase, vbase_addr, t,
|| nvtbl == IDENTIFIER_GLOBAL_VALUE (DECL_NAME (vtbl))) || nvtbl == IDENTIFIER_GLOBAL_VALUE (DECL_NAME (vtbl)))
{ {
/* Dup it if it isn't in local scope yet. */ /* Dup it if it isn't in local scope yet. */
nvtbl = build_decl (VAR_DECL, nvtbl = build_decl
DECL_NAME (vtbl), (VAR_DECL, DECL_NAME (vtbl),
TYPE_MAIN_VARIANT (TREE_TYPE (BINFO_VTABLE (binfo)))); TYPE_MAIN_VARIANT (TREE_TYPE (BINFO_VTABLE (binfo))));
DECL_ALIGN (nvtbl) = MAX (TYPE_ALIGN (double_type_node), DECL_ALIGN (nvtbl) = MAX (TYPE_ALIGN (double_type_node),
DECL_ALIGN (nvtbl)); DECL_ALIGN (nvtbl));
TREE_READONLY (nvtbl) = 0; TREE_READONLY (nvtbl) = 0;
DECL_ARTIFICIAL (nvtbl) = 1; DECL_ARTIFICIAL (nvtbl) = 1;
nvtbl = pushdecl (nvtbl); nvtbl = pushdecl (nvtbl);
init = NULL_TREE; init = NULL_TREE;
cp_finish_decl (nvtbl, init, NULL_TREE, 0, LOOKUP_ONLYCONVERTING); cp_finish_decl (nvtbl, init, NULL_TREE, 0,
DECL_VIRTUAL_P (nvtbl) = 1; LOOKUP_ONLYCONVERTING);
DECL_CONTEXT (nvtbl) = t;
/* 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), init = build (MODIFY_EXPR, TREE_TYPE (nvtbl),
nvtbl, vtbl); nvtbl, vtbl);
TREE_SIDE_EFFECTS (init) = 1; TREE_SIDE_EFFECTS (init) = 1;
expand_expr_stmt (init); expand_expr_stmt (init);
/* Update the vtable pointers as necessary. */ /* Update the vtable pointers as necessary. */
ref = build_vfield_ref (build_indirect_ref (addr, NULL_PTR), DECL_CONTEXT (CLASSTYPE_VFIELD (BINFO_TYPE (binfo)))); ref = build_vfield_ref
expand_expr_stmt (build_modify_expr (ref, NOP_EXPR, (build_indirect_ref (addr, NULL_PTR),
build_unary_op (ADDR_EXPR, nvtbl, 0))); 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); assemble_external (vtbl);
aref = build_array_ref (vtbl, idx); aref = build_array_ref (vtbl, idx);
naref = build_array_ref (nvtbl, idx); naref = build_array_ref (nvtbl, idx);
old_delta = build_component_ref (aref, delta_identifier, NULL_TREE, 0); old_delta = build_component_ref (aref, delta_identifier,
new_delta = build_component_ref (naref, delta_identifier, NULL_TREE, 0); 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 /* This is a upcast, so we have to add the offset for the
virtual base. */ virtual base. */
......
...@@ -781,7 +781,15 @@ digest_init (type, init, tail) ...@@ -781,7 +781,15 @@ digest_init (type, init, tail)
if (code == ARRAY_TYPE) 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 if ((typ1 == char_type_node
|| typ1 == signed_char_type_node || typ1 == signed_char_type_node
|| typ1 == unsigned_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