OSDN Git Service

fix bogus email for myself
[pf3gnuchains/gcc-fork.git] / gcc / cp / class.c
index 1bab07d..88db80f 100644 (file)
@@ -1,6 +1,6 @@
 /* Functions related to building classes and their related objects.
    Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Michael Tiemann (tiemann@cygnus.com)
 
@@ -506,10 +506,12 @@ build_simple_base_path (tree expr, tree binfo)
    assumed to be non-NULL.  */
 
 tree
-convert_to_base (tree object, tree type, bool check_access, bool nonnull)
+convert_to_base (tree object, tree type, bool check_access, bool nonnull,
+                tsubst_flags_t complain)
 {
   tree binfo;
   tree object_type;
+  base_access access;
 
   if (TYPE_PTR_P (TREE_TYPE (object)))
     {
@@ -519,8 +521,11 @@ convert_to_base (tree object, tree type, bool check_access, bool nonnull)
   else
     object_type = TREE_TYPE (object);
 
+  access = check_access ? ba_check : ba_unique;
+  if (!(complain & tf_error))
+    access |= ba_quiet;
   binfo = lookup_base (object_type, type,
-                      check_access ? ba_check : ba_unique,
+                      access,
                       NULL);
   if (!binfo || binfo == error_mark_node)
     return error_mark_node;
@@ -575,7 +580,7 @@ build_vfield_ref (tree datum, tree type)
   /* First, convert to the requested type.  */
   if (!same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (datum), type))
     datum = convert_to_base (datum, type, /*check_access=*/false,
-                            /*nonnull=*/true);
+                            /*nonnull=*/true, tf_warning_or_error);
 
   /* Second, the requested type may not be the owner of its own vptr.
      If not, convert to the base class that owns it.  We cannot use
@@ -2781,14 +2786,8 @@ check_bitfield_decl (tree field)
               && TREE_CODE (type) != BOOLEAN_TYPE)
        warning (0, "width of %q+D exceeds its type", field);
       else if (TREE_CODE (type) == ENUMERAL_TYPE
-              && (0 > compare_tree_int (w,
-                                        tree_int_cst_min_precision
-                                        (TYPE_MIN_VALUE (type),
-                                         TYPE_UNSIGNED (type)))
-                  ||  0 > compare_tree_int (w,
-                                            tree_int_cst_min_precision
-                                            (TYPE_MAX_VALUE (type),
-                                             TYPE_UNSIGNED (type)))))
+              && (0 > (compare_tree_int
+                       (w, TYPE_PRECISION (ENUM_UNDERLYING_TYPE (type))))))
        warning (0, "%q+D is too small to hold all values of %q#T", field, type);
     }
 
@@ -4177,6 +4176,34 @@ type_has_user_nondefault_constructor (tree t)
   return false;
 }
 
+/* Returns the defaulted constructor if T has one. Otherwise, returns
+   NULL_TREE.  */
+
+tree
+in_class_defaulted_default_constructor (tree t)
+{
+  tree fns, args;
+
+  if (!TYPE_HAS_USER_CONSTRUCTOR (t))
+    return NULL_TREE;
+
+  for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns))
+    {
+      tree fn = OVL_CURRENT (fns);
+
+      if (DECL_DEFAULTED_IN_CLASS_P (fn))
+       {
+         args = FUNCTION_FIRST_USER_PARMTYPE (fn);
+         while (args && TREE_PURPOSE (args))
+           args = TREE_CHAIN (args);
+         if (!args || args == void_list_node)
+           return fn;
+       }
+    }
+
+  return NULL_TREE;
+}
+
 /* Returns true iff FN is a user-provided function, i.e. user-declared
    and not defaulted at its first declaration; or explicit, private,
    protected, or non-const.  */
@@ -5938,6 +5965,34 @@ currently_open_derived_class (tree t)
   return NULL_TREE;
 }
 
+/* Returns the innermost class type which is not a lambda closure type.  */
+
+tree
+current_nonlambda_class_type (void)
+{
+  int i;
+
+  /* We start looking from 1 because entry 0 is from global scope,
+     and has no type.  */
+  for (i = current_class_depth; i > 0; --i)
+    {
+      tree c;
+      if (i == current_class_depth)
+       c = current_class_type;
+      else
+       {
+         if (current_class_stack[i].hidden)
+           break;
+         c = current_class_stack[i].type;
+       }
+      if (!c)
+       continue;
+      if (!LAMBDA_TYPE_P (c))
+       return c;
+    }
+  return NULL_TREE;
+}
+
 /* When entering a class scope, all enclosing class scopes' names with
    static meaning (static variables, static functions, types and
    enumerators) have to be visible.  This recursive function calls
@@ -6343,7 +6398,7 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t flags)
 
   flags &= ~tf_ptrmem_ok;
 
-  if (TREE_CODE (lhstype) == UNKNOWN_TYPE)
+  if (lhstype == unknown_type_node)
     {
       if (flags & tf_error)
        error ("not enough type information");