aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@gcc.gnu.org>1998-05-27 20:11:24 -0400
committerJason Merrill <jason@gcc.gnu.org>1998-05-27 20:11:24 -0400
commit8c90d6111171ea07b4cbc39789f898f4e304a69f (patch)
treeae8d630c5718531e7dff11707940dcb1487e4b65 /gcc
parentca379c1cd345853542f0198a1518348af403b1b2 (diff)
downloadgcc-8c90d6111171ea07b4cbc39789f898f4e304a69f.zip
gcc-8c90d6111171ea07b4cbc39789f898f4e304a69f.tar.gz
gcc-8c90d6111171ea07b4cbc39789f898f4e304a69f.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog11
-rw-r--r--gcc/cp/call.c6
-rw-r--r--gcc/cp/search.c33
-rw-r--r--gcc/cp/typeck2.c10
4 files changed, 46 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index f47ae94..d37a619 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,16 @@
+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>
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index fb280eb..f10aae8 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -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);
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index c0db057..f199b2f 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -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. */
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index e53f2ac..e27d86a 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -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