91th Cygnus<->FSF quick merge
[gcc.git] / gcc / cp / search.c
index 25e68e9203a710326f86ac36689faf17951b5998..fa69754e770d8ca149a0e416922bd0f29a3efa9f 100644 (file)
@@ -1,6 +1,6 @@
 /* Breadth-first and depth-first routines for
    searching multiple-inheritance lattice for GNU C++.
-   Copyright (C) 1987, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
+   Copyright (C) 1987, 89, 92, 93, 94, 95, 96, 1997 Free Software Foundation, Inc.
    Contributed by Michael Tiemann (tiemann@cygnus.com)
 
 This file is part of GNU CC.
@@ -245,9 +245,9 @@ static struct memoized_entry *
 my_new_memoized_entry (chain)
      struct memoized_entry *chain;
 {
-  struct memoized_entry *p =
-    (struct memoized_entry *)obstack_alloc (&type_obstack_entries,
-                                           sizeof (struct memoized_entry));
+  struct memoized_entry *p
+    (struct memoized_entry *)obstack_alloc (&type_obstack_entries,
+                                             sizeof (struct memoized_entry));
   bzero ((char *) p, sizeof (struct memoized_entry));
   MEMOIZED_CHAIN (p) = chain;
   MEMOIZED_UID (p) = ++my_memoized_entry_counter;
@@ -412,10 +412,10 @@ pop_memoized_context (use_old)
 /* Get a virtual binfo that is found inside BINFO's hierarchy that is
    the same type as the type given in PARENT.  To be optimal, we want
    the first one that is found by going through the least number of
-   virtual bases.  DEPTH should be NULL_PTR.  */
+   virtual bases.  */
 
 static tree
-get_vbase (parent, binfo, depth)
+get_vbase_1 (parent, binfo, depth)
      tree parent, binfo;
      unsigned int *depth;
 {
@@ -423,12 +423,6 @@ get_vbase (parent, binfo, depth)
   int i, n_baselinks;
   tree rval = NULL_TREE;
 
-  if (depth == 0)
-    {
-      unsigned int d = (unsigned int)-1;
-      return get_vbase (parent, binfo, &d);
-    }
-
   if (BINFO_TYPE (binfo) == parent && TREE_VIA_VIRTUAL (binfo))
     {
       *depth = 0;
@@ -449,7 +443,7 @@ get_vbase (parent, binfo, depth)
       if (*depth == 0)
        break;
 
-      nrval = get_vbase (parent, base_binfo, depth);
+      nrval = get_vbase_1 (parent, base_binfo, depth);
       if (nrval)
        rval = nrval;
     }
@@ -457,16 +451,25 @@ get_vbase (parent, binfo, depth)
   return rval;
 }
 
+tree
+get_vbase (parent, binfo)
+     tree parent;
+     tree binfo;
+{
+  unsigned int d = (unsigned int)-1;
+  return get_vbase_1 (parent, binfo, &d);
+}
+
 /* Convert EXPR to a virtual base class of type TYPE.  We know that
    EXPR is a non-null POINTER_TYPE to RECORD_TYPE.  We also know that
    the type of what expr points to has a virtual base of type TYPE.  */
 
-tree
+static tree
 convert_pointer_to_vbase (type, expr)
      tree type;
      tree expr;
 {
-  tree vb = get_vbase (type, TYPE_BINFO (TREE_TYPE (TREE_TYPE (expr))), NULL_PTR);
+  tree vb = get_vbase (type, TYPE_BINFO (TREE_TYPE (TREE_TYPE (expr))));
   return convert_pointer_to_real (vb, expr);
 }
 
@@ -851,9 +854,9 @@ compute_access (basetype_path, field)
   /* Replaces static decl above.  */
   tree previous_scope;
 #endif
-  int static_mem =
-    ((TREE_CODE (field) == FUNCTION_DECL && DECL_STATIC_FUNCTION_P (field))
-     || (TREE_CODE (field) != FUNCTION_DECL && TREE_STATIC (field)));
+  int static_mem
+    ((TREE_CODE (field) == FUNCTION_DECL && DECL_STATIC_FUNCTION_P (field))
+       || (TREE_CODE (field) != FUNCTION_DECL && TREE_STATIC (field)));
 
   if (! flag_access_control)
     return access_public_node;
@@ -1131,6 +1134,15 @@ lookup_field (xbasetype, name, protect, want_type)
     name = constructor_name (name);
 #endif
 
+  if (xbasetype == current_class_type && TYPE_BEING_DEFINED (xbasetype)
+      && IDENTIFIER_CLASS_VALUE (name))
+    {
+      tree field = IDENTIFIER_CLASS_VALUE (name);
+      if (TREE_CODE (field) != FUNCTION_DECL
+         && ! (want_type && TREE_CODE (field) != TYPE_DECL))
+       return field;
+    }
+
   if (TREE_CODE (xbasetype) == TREE_VEC)
     {
       type = BINFO_TYPE (xbasetype);
@@ -2170,8 +2182,8 @@ get_abstract_virtuals_1 (binfo, do_self, abstract_virtuals)
   for (i = 0; i < n_baselinks; i++)
     {
       tree base_binfo = TREE_VEC_ELT (binfos, i);
-      int is_not_base_vtable =
-       i != CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo));
+      int is_not_base_vtable
+       i != CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo));
       if (! TREE_VIA_VIRTUAL (base_binfo))
        abstract_virtuals
          = get_abstract_virtuals_1 (base_binfo, is_not_base_vtable,
@@ -2784,7 +2796,7 @@ expand_upcast_fixups (binfo, addr, orig_addr, vbase, vbase_addr, t,
          && (vc=virtual_context (current_fndecl, t, vbase)) != vbase)
        {
          /* This may in fact need a runtime fixup.  */
-         tree idx = DECL_VINDEX (current_fndecl);
+         tree idx = build_int_2 (n, 0);
          tree vtbl = BINFO_VTABLE (binfo);
          tree nvtbl = lookup_name (DECL_NAME (vtbl), 0);
          tree aref, ref, naref;
@@ -2875,8 +2887,8 @@ fixup_virtual_upcast_offsets (real_binfo, binfo, init_self, can_elide, addr, ori
     {
       tree real_base_binfo = TREE_VEC_ELT (real_binfos, i);
       tree base_binfo = TREE_VEC_ELT (binfos, i);
-      int is_not_base_vtable =
-       i != CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (real_binfo));
+      int is_not_base_vtable
+       i != CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (real_binfo));
       if (! TREE_VIA_VIRTUAL (real_base_binfo))
        fixup_virtual_upcast_offsets (real_base_binfo, base_binfo,
                                      is_not_base_vtable, can_elide, addr,
@@ -3149,7 +3161,6 @@ note_debug_info_needed (type)
 /* Subroutines of push_class_decls ().  */
 
 /* Add in a decl to the envelope.  */
-
 static void
 envelope_add_decl (type, decl, values)
      tree type, decl, *values;