OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / cp / search.c
index 8d5ae65..66bbb13 100644 (file)
@@ -18,8 +18,8 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 /* High-level class interface.  */
 
@@ -82,13 +82,13 @@ static int n_contexts_saved;
 struct lookup_base_data_s
 {
   tree t;              /* type being searched.  */
-  tree base;            /* The base type we're looking for.  */
-  tree binfo;           /* Found binfo.  */
-  bool via_virtual;    /* Found via a virtual path.  */
+  tree base;           /* The base type we're looking for.  */
+  tree binfo;          /* Found binfo.  */
+  bool via_virtual;    /* Found via a virtual path.  */
   bool ambiguous;      /* Found multiply ambiguous */
-  bool repeated_base;   /* Whether there are repeated bases in the
+  bool repeated_base;  /* Whether there are repeated bases in the
                            hierarchy.  */
-  bool want_any;       /* Whether we want any matching binfo.  */
+  bool want_any;       /* Whether we want any matching binfo.  */
 };
 
 /* Worker function for lookup_base.  See if we've found the desired
@@ -97,7 +97,7 @@ struct lookup_base_data_s
 static tree
 dfs_lookup_base (tree binfo, void *data_)
 {
-  struct lookup_base_data_s *data = data_;
+  struct lookup_base_data_s *data = (struct lookup_base_data_s *) data_;
 
   if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), data->base))
     {
@@ -106,22 +106,22 @@ dfs_lookup_base (tree binfo, void *data_)
          data->binfo = binfo;
          data->via_virtual
            = binfo_via_virtual (data->binfo, data->t) != NULL_TREE;
-         
+
          if (!data->repeated_base)
            /* If there are no repeated bases, we can stop now.  */
            return binfo;
-         
+
          if (data->want_any && !data->via_virtual)
            /* If this is a non-virtual base, then we can't do
               better.  */
            return binfo;
-         
+
          return dfs_skip_bases;
        }
       else
        {
          gcc_assert (binfo != data->binfo);
-         
+
          /* We've found more than one matching binfo.  */
          if (!data->want_any)
            {
@@ -144,7 +144,7 @@ dfs_lookup_base (tree binfo, void *data_)
          return dfs_skip_bases;
        }
     }
-  
+
   return NULL_TREE;
 }
 
@@ -161,7 +161,7 @@ accessible_base_p (tree t, tree base, bool consider_local_p)
   /* [class.access.base]
 
      A base class is said to be accessible if an invented public
-     member of the base class is accessible.  
+     member of the base class is accessible.
 
      If BASE is a non-proper base, this condition is trivially
      true.  */
@@ -193,7 +193,7 @@ lookup_base (tree t, tree base, base_access access, base_kind *kind_ptr)
   tree binfo;
   tree t_binfo;
   base_kind bk;
-  
+
   if (t == error_mark_node || base == error_mark_node)
     {
       if (kind_ptr)
@@ -201,7 +201,7 @@ lookup_base (tree t, tree base, base_access access, base_kind *kind_ptr)
       return error_mark_node;
     }
   gcc_assert (TYPE_P (base));
-  
+
   if (!TYPE_P (t))
     {
       t_binfo = t;
@@ -212,7 +212,7 @@ lookup_base (tree t, tree base, base_access access, base_kind *kind_ptr)
       t = complete_type (TYPE_MAIN_VARIANT (t));
       t_binfo = TYPE_BINFO (t);
     }
-  
+
   base = complete_type (TYPE_MAIN_VARIANT (base));
 
   if (t_binfo)
@@ -228,7 +228,7 @@ lookup_base (tree t, tree base, base_access access, base_kind *kind_ptr)
 
       dfs_walk_once (t_binfo, dfs_lookup_base, NULL, &data);
       binfo = data.binfo;
-      
+
       if (!binfo)
        bk = data.ambiguous ? bk_ambig : bk_not_base;
       else if (binfo == t_binfo)
@@ -284,7 +284,7 @@ lookup_base (tree t, tree base, base_access access, base_kind *kind_ptr)
 
   if (kind_ptr)
     *kind_ptr = bk;
-  
+
   return binfo;
 }
 
@@ -306,11 +306,11 @@ struct dcast_data_s
 static tree
 dfs_dcast_hint_pre (tree binfo, void *data_)
 {
-  struct dcast_data_s *data = data_;
+  struct dcast_data_s *data = (struct dcast_data_s *) data_;
 
   if (BINFO_VIRTUAL_P (binfo))
     data->virt_depth++;
-  
+
   if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), data->subtype))
     {
       if (data->virt_depth)
@@ -334,7 +334,7 @@ dfs_dcast_hint_pre (tree binfo, void *data_)
 static tree
 dfs_dcast_hint_post (tree binfo, void *data_)
 {
-  struct dcast_data_s *data = data_;
+  struct dcast_data_s *data = (struct dcast_data_s *) data_;
 
   if (BINFO_VIRTUAL_P (binfo))
     data->virt_depth--;
@@ -362,7 +362,7 @@ dcast_base_hint (tree subtype, tree target)
   data.virt_depth = 0;
   data.offset = NULL_TREE;
   data.repeated_base = CLASSTYPE_REPEATED_BASE_P (target);
-  
+
   dfs_walk_once_accessible (TYPE_BINFO (target), /*friends=*/false,
                            dfs_dcast_hint_pre, dfs_dcast_hint_post, &data);
   return data.offset ? data.offset : ssize_int (-2);
@@ -386,7 +386,7 @@ lookup_field_1 (tree type, tree name, bool want_type)
   if (TREE_CODE (type) == TEMPLATE_TYPE_PARM
       || TREE_CODE (type) == BOUND_TEMPLATE_TEMPLATE_PARM
       || TREE_CODE (type) == TYPENAME_TYPE)
-    /* The TYPE_FIELDS of a TEMPLATE_TYPE_PARM and 
+    /* The TYPE_FIELDS of a TEMPLATE_TYPE_PARM and
        BOUND_TEMPLATE_TEMPLATE_PARM are not fields at all;
        instead TYPE_FIELDS is the TEMPLATE_PARM_INDEX.  (Miraculously,
        the code often worked even when we treated the index as a list
@@ -471,14 +471,13 @@ lookup_field_1 (tree type, tree name, bool want_type)
             defined, USING_DECLs are purged from TYPE_FIELDS; see
             handle_using_decl.  However, we make special efforts to
             make using-declarations in class templates and class
-            template partial specializations work correctly noticing
-            that dependent USING_DECL's do not have TREE_TYPE set.  */
-         if (TREE_TYPE (field))
+            template partial specializations work correctly.  */
+         if (!DECL_DEPENDENT_P (field))
            continue;
        }
 
       if (DECL_NAME (field) == name
-         && (!want_type 
+         && (!want_type
              || TREE_CODE (field) == TYPE_DECL
              || DECL_CLASS_TEMPLATE_P (field)))
        return field;
@@ -494,7 +493,7 @@ lookup_field_1 (tree type, tree name, bool want_type)
 }
 
 /* Return the FUNCTION_DECL, RECORD_TYPE, UNION_TYPE, or
-   NAMESPACE_DECL corresponding to the innermost non-block scope.  */  
+   NAMESPACE_DECL corresponding to the innermost non-block scope.  */
 
 tree
 current_scope (void)
@@ -564,11 +563,11 @@ tree
 context_for_name_lookup (tree decl)
 {
   /* [class.union]
-     
+
      For the purposes of name lookup, after the anonymous union
      definition, the members of the anonymous union are considered to
      have been defined in the scope in which the anonymous union is
-     declared.  */ 
+     declared.  */
   tree context = DECL_CONTEXT (decl);
 
   while (context && TYPE_P (context) && ANON_AGGR_TYPE_P (context))
@@ -612,7 +611,7 @@ dfs_access_in_type (tree binfo, void *data)
       else
        access = ak_public;
     }
-  else 
+  else
     {
       /* First, check for an access-declaration that gives us more
         access to the DECL.  The CONST_DECL for an enumeration
@@ -621,11 +620,11 @@ dfs_access_in_type (tree binfo, void *data)
       if (DECL_LANG_SPECIFIC (decl) && !DECL_DISCRIMINATOR_P (decl))
        {
          tree decl_access = purpose_member (type, DECL_ACCESS (decl));
-         
+
          if (decl_access)
            {
              decl_access = TREE_VALUE (decl_access);
-             
+
              if (decl_access == access_public_node)
                access = ak_public;
              else if (decl_access == access_protected_node)
@@ -641,8 +640,8 @@ dfs_access_in_type (tree binfo, void *data)
        {
          int i;
          tree base_binfo;
-         VEC (tree) *accesses;
-         
+         VEC(tree,gc) *accesses;
+
          /* Otherwise, scan our baseclasses, and pick the most favorable
             access.  */
          accesses = BINFO_BASE_ACCESSES (binfo);
@@ -699,7 +698,7 @@ access_in_type (tree type, tree decl)
 
        If a name can be reached by several paths through a multiple
        inheritance graph, the access is that of the path that gives
-       most access.  
+       most access.
 
     The algorithm we use is to make a post-order depth-first traversal
     of the base-class hierarchy.  As we come up the tree, we annotate
@@ -722,7 +721,7 @@ protected_accessible_p (tree decl, tree derived, tree binfo)
        m as a member of N is protected, and the reference occurs in a
        member or friend of class N, or in a member or friend of a
        class P derived from N, where m as a member of P is private or
-       protected.  
+       protected.
 
     Here DERIVED is a possible P and DECL is m.  accessible_p will
     iterate over various values of N, but the access to m in DERIVED
@@ -742,7 +741,7 @@ protected_accessible_p (tree decl, tree derived, tree binfo)
   /* If m is inaccessible in DERIVED, then it's not a P.  */
   if (access == ak_none)
     return 0;
-  
+
   /* [class.protected]
 
      When a friend or a member function of a derived class references
@@ -761,7 +760,7 @@ protected_accessible_p (tree decl, tree derived, tree binfo)
       tree t = binfo;
       while (BINFO_INHERITANCE_CHAIN (t))
        t = BINFO_INHERITANCE_CHAIN (t);
-      
+
       if (!DERIVED_FROM_P (derived, BINFO_TYPE (t)))
        return 0;
     }
@@ -803,8 +802,8 @@ friend_accessible_p (tree scope, tree decl, tree binfo)
   if (TREE_CODE (scope) == FUNCTION_DECL
       || DECL_FUNCTION_TEMPLATE_P (scope))
     {
-      /* Perhaps this SCOPE is a member of a class which is a 
-        friend.  */ 
+      /* Perhaps this SCOPE is a member of a class which is a
+        friend.  */
       if (DECL_CLASS_SCOPE_P (scope)
          && friend_accessible_p (DECL_CONTEXT (scope), decl, binfo))
        return 1;
@@ -837,7 +836,7 @@ dfs_accessible_post (tree binfo, void *data ATTRIBUTE_UNUSED)
          && is_friend (BINFO_TYPE (binfo), scope))
        return binfo;
     }
-  
+
   return NULL_TREE;
 }
 
@@ -849,7 +848,7 @@ dfs_accessible_post (tree binfo, void *data ATTRIBUTE_UNUSED)
    CONSIDER_LOCAL is true, do consider special access the current
    scope or friendship thereof we might have.  */
 
-int 
+int
 accessible_p (tree type, tree decl, bool consider_local_p)
 {
   tree binfo;
@@ -873,8 +872,12 @@ accessible_p (tree type, tree decl, bool consider_local_p)
   /* In a template declaration, we cannot be sure whether the
      particular specialization that is instantiated will be a friend
      or not.  Therefore, all access checks are deferred until
-     instantiation.  */
-  if (processing_template_decl)
+     instantiation.  However, PROCESSING_TEMPLATE_DECL is set in the
+     parameter list for a template (because we may see dependent types
+     in default arguments for template parameters), and access
+     checking should be performed in the outermost parameter list.  */ 
+  if (processing_template_decl 
+      && (!processing_template_parmlist || processing_template_decl > 1))
     return 1;
 
   if (!TYPE_P (type))
@@ -900,7 +903,7 @@ accessible_p (tree type, tree decl, bool consider_local_p)
        protected, or
 
      --there exists a base class B of N that is accessible at the point
-       of reference, and m is accessible when named in class B.  
+       of reference, and m is accessible when named in class B.
 
     We walk the base class hierarchy, checking these conditions.  */
 
@@ -928,10 +931,10 @@ accessible_p (tree type, tree decl, bool consider_local_p)
   if (access == ak_public
       || (access == ak_protected && protected_ok))
     return 1;
-  
+
   if (!consider_local_p)
     return 0;
-  
+
   /* Walk the hierarchy again, looking for a base class that allows
      access.  */
   return dfs_walk_once_accessible (binfo, /*friends=*/true,
@@ -960,7 +963,7 @@ struct lookup_field_info {
 /* Within the scope of a template class, you can refer to the to the
    current specialization with the name of the template itself.  For
    example:
-   
+
      template <typename T> struct S { S* sp; }
 
    Returns nonzero if DECL is such a declaration in a class TYPE.  */
@@ -1012,7 +1015,7 @@ static int
 is_subobject_of_p (tree parent, tree binfo)
 {
   tree probe;
-  
+
   for (probe = parent; probe; probe = BINFO_INHERITANCE_CHAIN (probe))
     {
       if (probe == binfo)
@@ -1039,7 +1042,7 @@ lookup_field_r (tree binfo, void *data)
   /* If this is a dependent base, don't look in it.  */
   if (BINFO_DEPENDENT_BASE_P (binfo))
     return NULL_TREE;
-  
+
   /* If this base class is hidden by the best-known value so far, we
      don't need to look.  */
   if (lfi->rval_binfo && BINFO_INHERITANCE_CHAIN (binfo) == lfi->rval_binfo
@@ -1085,17 +1088,17 @@ lookup_field_r (tree binfo, void *data)
        nval = NULL_TREE;
       if (!nval && CLASSTYPE_NESTED_UTDS (type) != NULL)
        {
-          binding_entry e = binding_table_find (CLASSTYPE_NESTED_UTDS (type),
-                                                lfi->name);
+         binding_entry e = binding_table_find (CLASSTYPE_NESTED_UTDS (type),
+                                               lfi->name);
          if (e != NULL)
            nval = TYPE_MAIN_DECL (e->type);
-         else 
+         else
            goto done;
        }
     }
 
   /* You must name a template base class with a template-id.  */
-  if (!same_type_p (type, lfi->type) 
+  if (!same_type_p (type, lfi->type)
       && template_self_reference_p (type, nval))
     goto done;
 
@@ -1103,7 +1106,7 @@ lookup_field_r (tree binfo, void *data)
      hide the old one, we might have an ambiguity.  */
   if (lfi->rval_binfo
       && !is_subobject_of_p (lfi->rval_binfo, binfo))
-    
+
     {
       if (nval == lfi->rval && shared_member_p (nval))
        /* The two things are really the same.  */
@@ -1237,8 +1240,8 @@ lookup_member (tree xbasetype, tree name, int protect, bool want_type)
      just return NULL_TREE.  */
   if (!protect && lfi.ambiguous)
     return NULL_TREE;
-  
-  if (protect == 2) 
+
+  if (protect == 2)
     {
       if (lfi.ambiguous)
        return lfi.ambiguous;
@@ -1257,11 +1260,11 @@ lookup_member (tree xbasetype, tree name, int protect, bool want_type)
     {
       error (errstr, name, type);
       if (lfi.ambiguous)
-        print_candidates (lfi.ambiguous);
+       print_candidates (lfi.ambiguous);
       rval = error_mark_node;
     }
 
-  if (rval && is_overloaded_fn (rval)) 
+  if (rval && is_overloaded_fn (rval))
     rval = build_baselink (rval_binfo, basetype_path, rval,
                           (IDENTIFIER_TYPENAME_P (name)
                           ? TREE_TYPE (name): NULL_TREE));
@@ -1275,7 +1278,7 @@ tree
 lookup_field (tree xbasetype, tree name, int protect, bool want_type)
 {
   tree rval = lookup_member (xbasetype, name, protect, want_type);
-  
+
   /* Ignore functions, but propagate the ambiguity list.  */
   if (!error_operand_p (rval)
       && (rval && BASELINK_P (rval)))
@@ -1314,8 +1317,8 @@ lookup_conversion_operator (tree class_type, tree type)
     {
       int i;
       tree fn;
-      VEC(tree) *methods = CLASSTYPE_METHOD_VEC (class_type);
-      
+      VEC(tree,gc) *methods = CLASSTYPE_METHOD_VEC (class_type);
+
       for (i = CLASSTYPE_FIRST_CONVERSION_SLOT;
           VEC_iterate (tree, methods, i, fn); ++i)
        {
@@ -1326,7 +1329,7 @@ lookup_conversion_operator (tree class_type, tree type)
          fn = OVL_CURRENT (fn);
          if (!DECL_CONV_FN_P (fn))
            break;
-         
+
          if (TREE_CODE (fn) == TEMPLATE_DECL)
            /* All the templated conversion functions are on the same
               slot, so remember it.  */
@@ -1345,11 +1348,11 @@ lookup_conversion_operator (tree class_type, tree type)
 int
 lookup_fnfields_1 (tree type, tree name)
 {
-  VEC(tree) *method_vec;
+  VEC(tree,gc) *method_vec;
   tree fn;
   tree tmp;
   size_t i;
-  
+
   if (!CLASS_TYPE_P (type))
     return -1;
 
@@ -1367,6 +1370,12 @@ lookup_fnfields_1 (tree type, tree name)
       else if (name == ansi_assopname(NOP_EXPR)
               && CLASSTYPE_LAZY_ASSIGNMENT_OP (type))
        lazily_declare_fn (sfk_assignment_operator, type);
+      else if ((name == dtor_identifier
+               || name == base_dtor_identifier
+               || name == complete_dtor_identifier
+               || name == deleting_dtor_identifier)
+              && CLASSTYPE_LAZY_DESTRUCTOR (type))
+       lazily_declare_fn (sfk_destructor, type);
     }
 
   method_vec = CLASSTYPE_METHOD_VEC (type);
@@ -1466,11 +1475,11 @@ class_method_index_for_fn (tree class_type, tree function)
    `B', not `D'.  This function makes that adjustment.  */
 
 tree
-adjust_result_of_qualified_name_lookup (tree decl, 
+adjust_result_of_qualified_name_lookup (tree decl,
                                        tree qualifying_scope,
                                        tree context_class)
 {
-  if (context_class && CLASS_TYPE_P (qualifying_scope) 
+  if (context_class && CLASS_TYPE_P (qualifying_scope)
       && DERIVED_FROM_P (qualifying_scope, context_class)
       && BASELINK_P (decl))
     {
@@ -1488,7 +1497,7 @@ adjust_result_of_qualified_name_lookup (tree decl,
       if (base)
        {
          BASELINK_ACCESS_BINFO (decl) = base;
-         BASELINK_BINFO (decl) 
+         BASELINK_BINFO (decl)
            = lookup_base (base, BINFO_TYPE (BASELINK_BINFO (decl)),
                           ba_unique | ba_quiet,
                           NULL);
@@ -1516,7 +1525,7 @@ dfs_walk_all (tree binfo, tree (*pre_fn) (tree, void *),
   tree rval;
   unsigned ix;
   tree base_binfo;
-  
+
   /* Call the pre-order walking function.  */
   if (pre_fn)
     {
@@ -1545,7 +1554,7 @@ dfs_walk_all (tree binfo, tree (*pre_fn) (tree, void *),
       gcc_assert (rval != dfs_skip_bases);
       return rval;
     }
-  
+
   return NULL_TREE;
 }
 
@@ -1559,7 +1568,7 @@ dfs_walk_once_r (tree binfo, tree (*pre_fn) (tree, void *),
   tree rval;
   unsigned ix;
   tree base_binfo;
-  
+
   /* Call the pre-order walking function.  */
   if (pre_fn)
     {
@@ -1568,7 +1577,7 @@ dfs_walk_once_r (tree binfo, tree (*pre_fn) (tree, void *),
        {
          if (rval == dfs_skip_bases)
            goto skip_bases;
-         
+
          return rval;
        }
     }
@@ -1582,12 +1591,12 @@ dfs_walk_once_r (tree binfo, tree (*pre_fn) (tree, void *),
            continue;
          BINFO_MARKED (base_binfo) = 1;
        }
-  
+
       rval = dfs_walk_once_r (base_binfo, pre_fn, post_fn, data);
       if (rval)
        return rval;
     }
-  
+
  skip_bases:
   /* Call the post-order walking function.  */
   if (post_fn)
@@ -1596,19 +1605,19 @@ dfs_walk_once_r (tree binfo, tree (*pre_fn) (tree, void *),
       gcc_assert (rval != dfs_skip_bases);
       return rval;
     }
-  
+
   return NULL_TREE;
 }
 
 /* Worker for dfs_walk_once. Recursively unmark the virtual base binfos of
    BINFO.  */
-   
+
 static void
 dfs_unmark_r (tree binfo)
 {
   unsigned ix;
   tree base_binfo;
-  
+
   /* Process the basetypes.  */
   for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++)
     {
@@ -1633,10 +1642,13 @@ tree
 dfs_walk_once (tree binfo, tree (*pre_fn) (tree, void *),
               tree (*post_fn) (tree, void *), void *data)
 {
+  static int active = 0;  /* We must not be called recursively. */
   tree rval;
 
   gcc_assert (pre_fn || post_fn);
-  
+  gcc_assert (!active);
+  active++;
+
   if (!CLASSTYPE_DIAMOND_SHAPED_P (BINFO_TYPE (binfo)))
     /* We are not diamond shaped, and therefore cannot encounter the
        same binfo twice.  */
@@ -1647,12 +1659,12 @@ dfs_walk_once (tree binfo, tree (*pre_fn) (tree, void *),
       if (!BINFO_INHERITANCE_CHAIN (binfo))
        {
          /* We are at the top of the hierarchy, and can use the
-             CLASSTYPE_VBASECLASSES list for unmarking the virtual
-             bases.  */
-         VEC (tree) *vbases;
+            CLASSTYPE_VBASECLASSES list for unmarking the virtual
+            bases.  */
+         VEC(tree,gc) *vbases;
          unsigned ix;
          tree base_binfo;
-         
+
          for (vbases = CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo)), ix = 0;
               VEC_iterate (tree, vbases, ix, base_binfo); ix++)
            BINFO_MARKED (base_binfo) = 0;
@@ -1660,6 +1672,9 @@ dfs_walk_once (tree binfo, tree (*pre_fn) (tree, void *),
       else
        dfs_unmark_r (binfo);
     }
+
+  active--;
+
   return rval;
 }
 
@@ -1685,7 +1700,7 @@ dfs_walk_once_accessible_r (tree binfo, bool friends_p, bool once,
        {
          if (rval == dfs_skip_bases)
            goto skip_bases;
-         
+
          return rval;
        }
     }
@@ -1697,17 +1712,17 @@ dfs_walk_once_accessible_r (tree binfo, bool friends_p, bool once,
 
       if (mark && BINFO_MARKED (base_binfo))
        continue;
-  
+
       /* If the base is inherited via private or protected
-        inheritance, then we can't see it, unless we are a friend of
-        the current binfo.  */
+        inheritance, then we can't see it, unless we are a friend of
+        the current binfo.  */
       if (BINFO_BASE_ACCESS (binfo, ix) != access_public_node)
        {
          tree scope;
          if (!friends_p)
            continue;
          scope = current_scope ();
-         if (!scope 
+         if (!scope
              || TREE_CODE (scope) == NAMESPACE_DECL
              || !is_friend (BINFO_TYPE (binfo), scope))
            continue;
@@ -1721,7 +1736,7 @@ dfs_walk_once_accessible_r (tree binfo, bool friends_p, bool once,
       if (rval)
        return rval;
     }
-  
+
  skip_bases:
   /* Call the post-order walking function.  */
   if (post_fn)
@@ -1730,7 +1745,7 @@ dfs_walk_once_accessible_r (tree binfo, bool friends_p, bool once,
       gcc_assert (rval != dfs_skip_bases);
       return rval;
     }
-  
+
   return NULL_TREE;
 }
 
@@ -1746,18 +1761,18 @@ dfs_walk_once_accessible (tree binfo, bool friends_p,
   bool diamond_shaped = CLASSTYPE_DIAMOND_SHAPED_P (BINFO_TYPE (binfo));
   tree rval = dfs_walk_once_accessible_r (binfo, friends_p, diamond_shaped,
                                          pre_fn, post_fn, data);
-  
+
   if (diamond_shaped)
     {
       if (!BINFO_INHERITANCE_CHAIN (binfo))
        {
          /* We are at the top of the hierarchy, and can use the
-             CLASSTYPE_VBASECLASSES list for unmarking the virtual
-             bases.  */
-         VEC (tree) *vbases;
+            CLASSTYPE_VBASECLASSES list for unmarking the virtual
+            bases.  */
+         VEC(tree,gc) *vbases;
          unsigned ix;
          tree base_binfo;
-         
+
          for (vbases = CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo)), ix = 0;
               VEC_iterate (tree, vbases, ix, base_binfo); ix++)
            BINFO_MARKED (base_binfo) = 0;
@@ -1793,12 +1808,12 @@ check_final_overrider (tree overrider, tree basefn)
     {
       /* Potentially covariant.  */
       unsigned base_quals, over_quals;
-      
+
       fail = !POINTER_TYPE_P (base_return);
       if (!fail)
        {
          fail = cp_type_quals (base_return) != cp_type_quals (over_return);
-         
+
          base_return = TREE_TYPE (base_return);
          over_return = TREE_TYPE (over_return);
        }
@@ -1807,7 +1822,7 @@ check_final_overrider (tree overrider, tree basefn)
 
       if ((base_quals & over_quals) != over_quals)
        fail = 1;
-      
+
       if (CLASS_TYPE_P (base_return) && CLASS_TYPE_P (over_return))
        {
          tree binfo = lookup_base (over_return, base_return,
@@ -1828,9 +1843,9 @@ check_final_overrider (tree overrider, tree basefn)
            fail = 2;
          else
            {
-             cp_warning_at ("deprecated covariant return type for %q#D",
+             warning (0, "deprecated covariant return type for %q+#D",
                             overrider);
-             cp_warning_at ("  overriding %q#D", basefn);
+             warning (0, "  overriding %q+#D", basefn);
            }
        }
       else
@@ -1844,38 +1859,37 @@ check_final_overrider (tree overrider, tree basefn)
     {
       if (fail == 1)
        {
-         cp_error_at ("invalid covariant return type for %q#D", overrider);
-         cp_error_at ("  overriding %q#D", basefn);
+         error ("invalid covariant return type for %q+#D", overrider);
+         error ("  overriding %q+#D", basefn);
        }
       else
        {
-         cp_error_at ("conflicting return type specified for %q#D",
-                      overrider);
-         cp_error_at ("  overriding %q#D", basefn);
+         error ("conflicting return type specified for %q+#D", overrider);
+         error ("  overriding %q+#D", basefn);
        }
       DECL_INVALID_OVERRIDER_P (overrider) = 1;
       return 0;
     }
-  
+
   /* Check throw specifier is at least as strict.  */
   if (!comp_except_specs (base_throw, over_throw, 0))
     {
-      cp_error_at ("looser throw specifier for %q#F", overrider);
-      cp_error_at ("  overriding %q#F", basefn);
+      error ("looser throw specifier for %q+#F", overrider);
+      error ("  overriding %q+#F", basefn);
       DECL_INVALID_OVERRIDER_P (overrider) = 1;
       return 0;
     }
-  
+
   return 1;
 }
 
 /* Given a class TYPE, and a function decl FNDECL, look for
    virtual functions in TYPE's hierarchy which FNDECL overrides.
    We do not look in TYPE itself, only its bases.
-   
+
    Returns nonzero, if we find any. Set FNDECL's DECL_VIRTUAL_P, if we
    find that it overrides anything.
-   
+
    We check that every function which is overridden, is correctly
    overridden.  */
 
@@ -1890,9 +1904,9 @@ look_for_overrides (tree type, tree fndecl)
   for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++)
     {
       tree basetype = BINFO_TYPE (base_binfo);
-      
+
       if (TYPE_POLYMORPHIC_P (basetype))
-        found += look_for_overrides_r (basetype, fndecl);
+       found += look_for_overrides_r (basetype, fndecl);
     }
   return found;
 }
@@ -1918,23 +1932,23 @@ look_for_overrides_here (tree type, tree fndecl)
   if (ix >= 0)
     {
       tree fns = VEC_index (tree, CLASSTYPE_METHOD_VEC (type), ix);
-  
+
       for (; fns; fns = OVL_NEXT (fns))
-        {
-          tree fn = OVL_CURRENT (fns);
+       {
+         tree fn = OVL_CURRENT (fns);
 
-          if (!DECL_VIRTUAL_P (fn))
-            /* Not a virtual.  */;
-          else if (DECL_CONTEXT (fn) != type)
-            /* Introduced with a using declaration.  */;
+         if (!DECL_VIRTUAL_P (fn))
+           /* Not a virtual.  */;
+         else if (DECL_CONTEXT (fn) != type)
+           /* Introduced with a using declaration.  */;
          else if (DECL_STATIC_FUNCTION_P (fndecl))
            {
              tree btypes = TYPE_ARG_TYPES (TREE_TYPE (fn));
              tree dtypes = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
-             if (compparms (TREE_CHAIN (btypes), dtypes))
+             if (compparms (TREE_CHAIN (btypes), dtypes))
                return fn;
-            }
-          else if (same_signature_p (fndecl, fn))
+           }
+         else if (same_signature_p (fndecl, fn))
            return fn;
        }
     }
@@ -1954,8 +1968,8 @@ look_for_overrides_r (tree type, tree fndecl)
        {
          /* A static member function cannot match an inherited
             virtual member function.  */
-         cp_error_at ("%q#D cannot be declared", fndecl);
-         cp_error_at ("  since %q#D declared in base class", fn);
+         error ("%q+#D cannot be declared", fndecl);
+         error ("  since %q+#D declared in base class", fn);
        }
       else
        {
@@ -1983,12 +1997,12 @@ dfs_get_pure_virtuals (tree binfo, void *data)
   if (!BINFO_PRIMARY_P (binfo))
     {
       tree virtuals;
-      
+
       for (virtuals = BINFO_VIRTUALS (binfo);
           virtuals;
           virtuals = TREE_CHAIN (virtuals))
        if (DECL_PURE_VIRTUAL_P (BV_FN (virtuals)))
-         VEC_safe_push (tree, CLASSTYPE_PURE_VIRTUALS (type),
+         VEC_safe_push (tree, gc, CLASSTYPE_PURE_VIRTUALS (type),
                         BV_FN (virtuals));
     }
 
@@ -2028,6 +2042,10 @@ maybe_suppress_debug_info (tree t)
   /* We might have set this earlier in cp_finish_decl.  */
   TYPE_DECL_SUPPRESS_DEBUG (TYPE_MAIN_DECL (t)) = 0;
 
+  /* Always emit the information for each class every time. */
+  if (flag_emit_class_debug_always)
+    return;
+
   /* If we already know how we're handling this class, handle debug info
      the same way.  */
   if (CLASSTYPE_INTERFACE_KNOWN (t))
@@ -2138,17 +2156,17 @@ check_hidden_convs (tree binfo, int virtual_depth, int virtualness,
   if (virtual_depth || virtualness)
     {
      /* In a virtual hierarchy, we could be hidden, or could hide a
-        conversion function on the other_convs list.  */
+       conversion function on the other_convs list.  */
       for (level = other_convs; level; level = TREE_CHAIN (level))
        {
          int we_hide_them;
          int they_hide_us;
          tree *prev, other;
-         
+
          if (!(virtual_depth || TREE_STATIC (level)))
            /* Neither is morally virtual, so cannot hide each other.  */
            continue;
-         
+
          if (!TREE_VALUE (level))
            /* They evaporated away already.  */
            continue;
@@ -2161,7 +2179,7 @@ check_hidden_convs (tree binfo, int virtual_depth, int virtualness,
          if (!(we_hide_them || they_hide_us))
            /* Neither is within the other, so no hiding can occur.  */
            continue;
-         
+
          for (prev = &TREE_VALUE (level), other = *prev; other;)
            {
              if (same_type_p (to_type, TREE_TYPE (other)))
@@ -2201,12 +2219,12 @@ split_conversions (tree my_convs, tree parent_convs,
 {
   tree t;
   tree prev;
-  
+
   /* Remove the original other_convs portion from child_convs.  */
   for (prev = NULL, t = child_convs;
        t != other_convs; prev = t, t = TREE_CHAIN (t))
     continue;
-  
+
   if (prev)
     TREE_CHAIN (prev) = NULL_TREE;
   else
@@ -2220,7 +2238,7 @@ split_conversions (tree my_convs, tree parent_convs,
     }
   else
     my_convs = child_convs;
-  
+
   return my_convs;
 }
 
@@ -2258,22 +2276,22 @@ lookup_conversions_r (tree binfo,
   tree child_tpl_convs = NULL_TREE;
   unsigned i;
   tree base_binfo;
-  VEC(tree) *method_vec = CLASSTYPE_METHOD_VEC (BINFO_TYPE (binfo));
+  VEC(tree,gc) *method_vec = CLASSTYPE_METHOD_VEC (BINFO_TYPE (binfo));
   tree conv;
 
   /* If we have no conversion operators, then don't look.  */
   if (!TYPE_HAS_CONVERSION (BINFO_TYPE (binfo)))
     {
       *convs = *tpl_convs = NULL_TREE;
-      
+
       return 0;
     }
-  
+
   if (BINFO_VIRTUAL_P (binfo))
     virtual_depth++;
-  
+
   /* First, locate the unhidden ones at this level.  */
-  for (i = CLASSTYPE_FIRST_CONVERSION_SLOT; 
+  for (i = CLASSTYPE_FIRST_CONVERSION_SLOT;
        VEC_iterate (tree, method_vec, i, conv);
        ++i)
     {
@@ -2292,7 +2310,7 @@ lookup_conversions_r (tree binfo,
            {
              tree tpl = OVL_CURRENT (tpls);
              tree type = DECL_CONV_FN_TYPE (tpl);
-             
+
              if (check_hidden_convs (binfo, virtual_depth, virtualness,
                                      type, parent_tpl_convs, other_tpl_convs))
                {
@@ -2313,7 +2331,7 @@ lookup_conversions_r (tree binfo,
          if (!IDENTIFIER_MARKED (name))
            {
              tree type = DECL_CONV_FN_TYPE (cur);
-             
+
              if (check_hidden_convs (binfo, virtual_depth, virtualness,
                                      type, parent_convs, other_convs))
                {
@@ -2336,17 +2354,17 @@ lookup_conversions_r (tree binfo,
       if (virtual_depth)
        TREE_STATIC (parent_convs) = 1;
     }
-  
+
   if (my_tpl_convs)
     {
       parent_tpl_convs = tree_cons (binfo, my_tpl_convs, parent_tpl_convs);
       if (virtual_depth)
-       TREE_STATIC (parent_convs) = 1;
+       TREE_STATIC (parent_tpl_convs) = 1;
     }
 
   child_convs = other_convs;
   child_tpl_convs = other_tpl_convs;
-  
+
   /* Now iterate over each base, looking for more conversions.  */
   for (i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++)
     {
@@ -2372,7 +2390,7 @@ lookup_conversions_r (tree binfo,
                              child_convs, other_convs);
   *tpl_convs = split_conversions (my_tpl_convs, parent_tpl_convs,
                                  child_tpl_convs, other_tpl_convs);
-  
+
   return my_virtualness;
 }
 
@@ -2390,15 +2408,15 @@ lookup_conversions (tree type)
 {
   tree convs, tpl_convs;
   tree list = NULL_TREE;
-  
+
   complete_type (type);
   if (!TYPE_BINFO (type))
     return NULL_TREE;
-  
+
   lookup_conversions_r (TYPE_BINFO (type), 0, 0,
                        NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE,
                        &convs, &tpl_convs);
-  
+
   /* Flatten the list-of-lists */
   for (; convs; convs = TREE_CHAIN (convs))
     {
@@ -2412,7 +2430,7 @@ lookup_conversions (tree type)
          list = probe;
        }
     }
-  
+
   for (; tpl_convs; tpl_convs = TREE_CHAIN (tpl_convs))
     {
       tree probe, next;
@@ -2425,7 +2443,7 @@ lookup_conversions (tree type)
          list = probe;
        }
     }
-  
+
   return list;
 }
 
@@ -2453,7 +2471,7 @@ binfo_via_virtual (tree binfo, tree limit)
   if (limit && !CLASSTYPE_VBASECLASSES (limit))
     /* LIMIT has no virtual bases, so BINFO cannot be via one.  */
     return NULL_TREE;
-  
+
   for (; binfo && !SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), limit);
        binfo = BINFO_INHERITANCE_CHAIN (binfo))
     {
@@ -2471,7 +2489,7 @@ tree
 copied_binfo (tree binfo, tree here)
 {
   tree result = NULL_TREE;
-  
+
   if (BINFO_VIRTUAL_P (binfo))
     {
       tree t;
@@ -2487,7 +2505,7 @@ copied_binfo (tree binfo, tree here)
       tree cbinfo;
       tree base_binfo;
       int ix;
-      
+
       cbinfo = copied_binfo (BINFO_INHERITANCE_CHAIN (binfo), here);
       for (ix = 0; BINFO_BASE_ITERATE (cbinfo, ix, base_binfo); ix++)
        if (SAME_BINFO_TYPE_P (BINFO_TYPE (base_binfo), BINFO_TYPE (binfo)))
@@ -2511,8 +2529,8 @@ binfo_for_vbase (tree base, tree t)
 {
   unsigned ix;
   tree binfo;
-  VEC (tree) *vbases;
-  
+  VEC(tree,gc) *vbases;
+
   for (vbases = CLASSTYPE_VBASECLASSES (t), ix = 0;
        VEC_iterate (tree, vbases, ix, binfo); ix++)
     if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), base))
@@ -2529,7 +2547,7 @@ tree
 original_binfo (tree binfo, tree here)
 {
   tree result = NULL;
-  
+
   if (SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), BINFO_TYPE (here)))
     result = here;
   else if (BINFO_VIRTUAL_P (binfo))
@@ -2539,13 +2557,13 @@ original_binfo (tree binfo, tree here)
   else if (BINFO_INHERITANCE_CHAIN (binfo))
     {
       tree base_binfos;
-      
+
       base_binfos = original_binfo (BINFO_INHERITANCE_CHAIN (binfo), here);
       if (base_binfos)
        {
          int ix;
          tree base_binfo;
-         
+
          for (ix = 0; (base_binfo = BINFO_BASE_BINFO (base_binfos, ix)); ix++)
            if (SAME_BINFO_TYPE_P (BINFO_TYPE (base_binfo),
                                   BINFO_TYPE (binfo)))
@@ -2555,7 +2573,7 @@ original_binfo (tree binfo, tree here)
              }
        }
     }
-  
+
   return result;
 }