]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
call.c (build_method_call): Make sure get_type_value returns something before we...
authorJason Merrill <jason@gcc.gnu.org>
Thu, 28 May 1998 00:11:24 +0000 (20:11 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 28 May 1998 00:11:24 +0000 (20:11 -0400)
* 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

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/search.c
gcc/cp/typeck2.c

index f47ae9459ee0576a90ac36becfb262f434912e2d..d37a619fbfcf76726f8fd4a372a23da049c46897 100644 (file)
@@ -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>
index fb280ebf2bf73017f7838bfb3af4729ce2bccf7c..f10aae85a7db90924aea02cee4fb26da10e2cd1e 100644 (file)
@@ -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);
index c0db0572ee506a530fe54c6c68cd80ff5b50cd1c..f199b2f2cc18acf7e6a1760df8b9ada179bc6cb8 100644 (file)
@@ -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.  */
index e53f2ac14ba3aa7c156835d35b9823417d18f156..e27d86a3a3c9b2ca7f0185f55ebdf22c52bd18aa 100644 (file)
@@ -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