]> gcc.gnu.org Git - gcc.git/blobdiff - gcc/cp/class.c
re PR c++/45984 (ICE: canonical types differ for identical types)
[gcc.git] / gcc / cp / class.c
index ed7367c95c44454f745254cf3d688fca18b8240c..f76c2bed3d8591fa5833c1d4915ce62d33863951 100644 (file)
@@ -130,7 +130,7 @@ static void finish_struct_methods (tree);
 static void maybe_warn_about_overly_private_class (tree);
 static int method_name_cmp (const void *, const void *);
 static int resort_method_name_cmp (const void *, const void *);
-static void add_implicitly_declared_members (tree, int, int, int, int);
+static void add_implicitly_declared_members (tree, int, int);
 static tree fixed_type_or_null (tree, int *, int *);
 static tree build_simple_base_path (tree expr, tree binfo);
 static tree build_vtbl_ref_1 (tree, tree);
@@ -139,13 +139,13 @@ static void build_vtbl_initializer (tree, tree, tree, tree, int *,
 static int count_fields (tree);
 static int add_fields_to_record_type (tree, struct sorted_fields_type*, int);
 static bool check_bitfield_decl (tree);
-static void check_field_decl (tree, tree, int *, int *, int *, int *, int *);
-static void check_field_decls (tree, tree *, int *, int *, int *, int *);
+static void check_field_decl (tree, tree, int *, int *, int *);
+static void check_field_decls (tree, tree *, int *, int *);
 static tree *build_base_field (record_layout_info, tree, splay_tree, tree *);
 static void build_base_fields (record_layout_info, splay_tree, tree *);
 static void check_methods (tree);
 static void remove_zero_width_bit_fields (tree);
-static void check_bases (tree, int *, int *, int *, int *);
+static void check_bases (tree, int *, int *);
 static void check_bases_and_members (tree);
 static tree create_vtable_ptr (tree, tree *);
 static void include_empty_classes (record_layout_info);
@@ -282,7 +282,7 @@ build_base_path (enum tree_code code,
 
   if (!want_pointer)
     /* This must happen before the call to save_expr.  */
-    expr = cp_build_unary_op (ADDR_EXPR, expr, 0, tf_warning_or_error);
+    expr = cp_build_addr_expr (expr, tf_warning_or_error);
   else
     expr = mark_rvalue_use (expr);
 
@@ -469,7 +469,7 @@ build_simple_base_path (tree expr, tree binfo)
   expr = build_simple_base_path (expr, d_binfo);
 
   for (field = TYPE_FIELDS (BINFO_TYPE (d_binfo));
-       field; field = TREE_CHAIN (field))
+       field; field = DECL_CHAIN (field))
     /* Is this the base field created by build_base_field?  */
     if (TREE_CODE (field) == FIELD_DECL
        && DECL_FIELD_IS_BASE (field)
@@ -557,8 +557,7 @@ convert_to_base_statically (tree expr, tree base)
         when processing a template because they do not handle C++-specific
         trees.  */
       gcc_assert (!processing_template_decl);
-      expr = cp_build_unary_op (ADDR_EXPR, expr, /*noconvert=*/1, 
-                             tf_warning_or_error);
+      expr = cp_build_addr_expr (expr, tf_warning_or_error);
       if (!integer_zerop (BINFO_OFFSET (base)))
         expr = fold_build2_loc (input_location,
                            POINTER_PLUS_EXPR, pointer_type, expr,
@@ -661,8 +660,7 @@ build_vfn_ref (tree instance_ptr, tree idx)
      vtable entry is treated as a function pointer.  */
   if (TARGET_VTABLE_USES_DESCRIPTORS)
     aref = build1 (NOP_EXPR, TREE_TYPE (aref),
-                  cp_build_unary_op (ADDR_EXPR, aref, /*noconvert=*/1,
-                                   tf_warning_or_error));
+                  cp_build_addr_expr (aref, tf_warning_or_error));
 
   /* Remember this as a method reference, for later devirtualization.  */
   aref = build3 (OBJ_TYPE_REF, TREE_TYPE (aref), aref, instance_ptr, idx);
@@ -1249,9 +1247,7 @@ handle_using_decl (tree using_decl, tree t)
 static void
 check_bases (tree t,
             int* cant_have_const_ctor_p,
-            int* no_const_asn_ref_p,
-            int* cant_have_lazy_ctor,
-            int* cant_have_lazy_opeq)
+            int* no_const_asn_ref_p)
 {
   int i;
   int seen_non_virtual_nearly_empty_base_p;
@@ -1262,7 +1258,7 @@ check_bases (tree t,
   seen_non_virtual_nearly_empty_base_p = 0;
 
   if (!CLASSTYPE_NON_STD_LAYOUT (t))
-    for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field))
+    for (field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field))
       if (TREE_CODE (field) == FIELD_DECL)
        break;
 
@@ -1290,10 +1286,6 @@ check_bases (tree t,
       if (TYPE_HAS_COPY_ASSIGN (basetype)
          && !TYPE_HAS_CONST_COPY_ASSIGN (basetype))
        *no_const_asn_ref_p = 1;
-      if (TYPE_HAS_USER_CONSTRUCTOR (basetype))
-       *cant_have_lazy_ctor = 1;
-      if (TYPE_HAS_USER_OPEQ (basetype))
-       *cant_have_lazy_opeq = 1;
 
       if (BINFO_VIRTUAL_P (base_binfo))
        /* A virtual base does not effect nearly emptiness.  */
@@ -1351,7 +1343,7 @@ check_bases (tree t,
               members, or has no base classes with non-static data
               members */
            for (basefield = TYPE_FIELDS (basetype); basefield;
-                basefield = TREE_CHAIN (basefield))
+                basefield = DECL_CHAIN (basefield))
              if (TREE_CODE (basefield) == FIELD_DECL)
                {
                  if (field)
@@ -1523,12 +1515,31 @@ fixup_type_variants (tree t)
       TYPE_VFIELD (variants) = TYPE_VFIELD (t);
       TYPE_METHODS (variants) = TYPE_METHODS (t);
       TYPE_FIELDS (variants) = TYPE_FIELDS (t);
+    }
+}
+
+/* Early variant fixups: we apply attributes at the beginning of the class
+   definition, and we need to fix up any variants that have already been
+   made via elaborated-type-specifier so that check_qualified_type works.  */
+
+void
+fixup_attribute_variants (tree t)
+{
+  tree variants;
 
-      /* All variants of a class have the same attributes.  */
+  if (!t)
+    return;
+
+  for (variants = TYPE_NEXT_VARIANT (t);
+       variants;
+       variants = TYPE_NEXT_VARIANT (variants))
+    {
+      /* These are the two fields that check_qualified_type looks at and
+        are affected by attributes.  */
       TYPE_ATTRIBUTES (variants) = TYPE_ATTRIBUTES (t);
+      TYPE_ALIGN (variants) = TYPE_ALIGN (t);
     }
 }
-
 \f
 /* Set memoizing fields and bits of T (and its variants) for later
    use.  */
@@ -1609,7 +1620,7 @@ maybe_warn_about_overly_private_class (tree t)
      functions are private.  (Since there are no friends or
      non-private statics, we can't ever call any of the private member
      functions.)  */
-  for (fn = TYPE_METHODS (t); fn; fn = TREE_CHAIN (fn))
+  for (fn = TYPE_METHODS (t); fn; fn = DECL_CHAIN (fn))
     /* We're not interested in compiler-generated methods; they don't
        provide any way to call private members.  */
     if (!DECL_ARTIFICIAL (fn))
@@ -1814,7 +1825,7 @@ finish_struct_methods (tree t)
 
   /* Clear DECL_IN_AGGR_P for all functions.  */
   for (fn_fields = TYPE_METHODS (t); fn_fields;
-       fn_fields = TREE_CHAIN (fn_fields))
+       fn_fields = DECL_CHAIN (fn_fields))
     DECL_IN_AGGR_P (fn_fields) = 0;
 
   /* Issue warnings about private constructors and such.  If there are
@@ -2054,7 +2065,7 @@ get_vcall_index (tree fn, tree type)
   tree_pair_p p;
   unsigned ix;
 
-  for (ix = 0; VEC_iterate (tree_pair_s, indices, ix, p); ix++)
+  FOR_EACH_VEC_ELT (tree_pair_s, indices, ix, p)
     if ((DECL_DESTRUCTOR_P (fn) && DECL_DESTRUCTOR_P (p->purpose))
        || same_signature_p (fn, p->purpose))
       return p->value;
@@ -2545,7 +2556,7 @@ finish_struct_anon (tree t)
 {
   tree field;
 
-  for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field))
+  for (field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field))
     {
       if (TREE_STATIC (field))
        continue;
@@ -2557,7 +2568,7 @@ finish_struct_anon (tree t)
        {
          bool is_union = TREE_CODE (TREE_TYPE (field)) == UNION_TYPE;
          tree elt = TYPE_FIELDS (TREE_TYPE (field));
-         for (; elt; elt = TREE_CHAIN (elt))
+         for (; elt; elt = DECL_CHAIN (elt))
            {
              /* We're generally only interested in entities the user
                 declared, but we also find nested classes by noticing
@@ -2634,9 +2645,7 @@ maybe_add_class_template_decl_list (tree type, tree t, int friend_p)
 static void
 add_implicitly_declared_members (tree t,
                                 int cant_have_const_cctor,
-                                int cant_have_const_assignment,
-                                int cant_have_lazy_ctor,
-                                int cant_have_lazy_opeq)
+                                int cant_have_const_assignment)
 {
   /* Destructor.  */
   if (!CLASSTYPE_DESTRUCTORS (t))
@@ -2690,26 +2699,6 @@ add_implicitly_declared_members (tree t,
        CLASSTYPE_LAZY_MOVE_ASSIGN (t) = 1;
     }
 
-  /* If a base or member type has a user-declared constructor or operator=,
-     we need to declare ours now to avoid issues with circular lazy
-     declarations (cpp0x/implicit6.C).  */
-  if (cant_have_lazy_ctor)
-    {
-      if (CLASSTYPE_LAZY_DEFAULT_CTOR (t))
-       lazily_declare_fn (sfk_constructor, t);
-      if (CLASSTYPE_LAZY_COPY_CTOR (t))
-       lazily_declare_fn (sfk_copy_constructor, t);
-      if (CLASSTYPE_LAZY_MOVE_CTOR (t))
-       lazily_declare_fn (sfk_move_constructor, t);
-    }
-  if (cant_have_lazy_opeq)
-    {
-      if (CLASSTYPE_LAZY_COPY_ASSIGN (t))
-       lazily_declare_fn (sfk_copy_assignment, t);
-      if (CLASSTYPE_LAZY_MOVE_ASSIGN (t))
-       lazily_declare_fn (sfk_move_assignment, t);
-    }
-
   /* We can't be lazy about declaring functions that might override
      a virtual function from a base class.  */
   if (TYPE_POLYMORPHIC_P (t)
@@ -2750,7 +2739,7 @@ count_fields (tree fields)
 {
   tree x;
   int n_fields = 0;
-  for (x = fields; x; x = TREE_CHAIN (x))
+  for (x = fields; x; x = DECL_CHAIN (x))
     {
       if (TREE_CODE (x) == FIELD_DECL && ANON_AGGR_TYPE_P (TREE_TYPE (x)))
        n_fields += count_fields (TYPE_FIELDS (TREE_TYPE (x)));
@@ -2767,7 +2756,7 @@ static int
 add_fields_to_record_type (tree fields, struct sorted_fields_type *field_vec, int idx)
 {
   tree x;
-  for (x = fields; x; x = TREE_CHAIN (x))
+  for (x = fields; x; x = DECL_CHAIN (x))
     {
       if (TREE_CODE (x) == FIELD_DECL && ANON_AGGR_TYPE_P (TREE_TYPE (x)))
        idx = add_fields_to_record_type (TYPE_FIELDS (TREE_TYPE (x)), field_vec, idx);
@@ -2858,15 +2847,13 @@ check_field_decl (tree field,
                  tree t,
                  int* cant_have_const_ctor,
                  int* no_const_asn_ref,
-                 int* any_default_members,
-                 int* cant_have_lazy_ctor,
-                 int* cant_have_lazy_opeq)
+                 int* any_default_members)
 {
   tree type = strip_array_types (TREE_TYPE (field));
 
-  /* An anonymous union cannot contain any fields which would change
+  /* In C++98 an anonymous union cannot contain any fields which would change
      the settings of CANT_HAVE_CONST_CTOR and friends.  */
-  if (ANON_UNION_TYPE_P (type))
+  if (ANON_UNION_TYPE_P (type) && cxx_dialect < cxx0x)
     ;
   /* And, we don't set TYPE_HAS_CONST_COPY_CTOR, etc., for anonymous
      structs.  So, we recurse through their fields here.  */
@@ -2874,11 +2861,10 @@ check_field_decl (tree field,
     {
       tree fields;
 
-      for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
+      for (fields = TYPE_FIELDS (type); fields; fields = DECL_CHAIN (fields))
        if (TREE_CODE (fields) == FIELD_DECL && !DECL_C_BIT_FIELD (field))
          check_field_decl (fields, t, cant_have_const_ctor,
-                           no_const_asn_ref, any_default_members,
-                           cant_have_lazy_ctor, cant_have_lazy_opeq);
+                           no_const_asn_ref, any_default_members);
     }
   /* Check members with class type for constructors, destructors,
      etc.  */
@@ -2888,8 +2874,10 @@ check_field_decl (tree field,
         make it through without complaint.  */
       abstract_virtuals_error (field, type);
 
-      if (TREE_CODE (t) == UNION_TYPE)
+      if (TREE_CODE (t) == UNION_TYPE && cxx_dialect < cxx0x)
        {
+         static bool warned;
+         int oldcount = errorcount;
          if (TYPE_NEEDS_CONSTRUCTING (type))
            error ("member %q+#D with constructor not allowed in union",
                   field);
@@ -2898,8 +2886,12 @@ check_field_decl (tree field,
          if (TYPE_HAS_COMPLEX_COPY_ASSIGN (type))
            error ("member %q+#D with copy assignment operator not allowed in union",
                   field);
-         /* Don't bother diagnosing move assop now; C++0x has more
-            flexible unions.  */
+         if (!warned && errorcount > oldcount)
+           {
+             inform (DECL_SOURCE_LOCATION (field), "unrestricted unions "
+                     "only available with -std=c++0x or -std=gnu++0x");
+             warned = true;
+           }
        }
       else
        {
@@ -2924,11 +2916,6 @@ check_field_decl (tree field,
       if (TYPE_HAS_COPY_ASSIGN (type)
          && !TYPE_HAS_CONST_COPY_ASSIGN (type))
        *no_const_asn_ref = 1;
-
-      if (TYPE_HAS_USER_CONSTRUCTOR (type))
-       *cant_have_lazy_ctor = 1;
-      if (TYPE_HAS_USER_OPEQ (type))
-       *cant_have_lazy_opeq = 1;
     }
   if (DECL_INITIAL (field) != NULL_TREE)
     {
@@ -2968,9 +2955,7 @@ check_field_decl (tree field,
 static void
 check_field_decls (tree t, tree *access_decls,
                   int *cant_have_const_ctor_p,
-                  int *no_const_asn_ref_p,
-                  int *cant_have_lazy_ctor_p,
-                  int *cant_have_lazy_opeq_p)
+                  int *no_const_asn_ref_p)
 {
   tree *field;
   tree *next;
@@ -2993,12 +2978,12 @@ check_field_decls (tree t, tree *access_decls,
       tree type = TREE_TYPE (x);
       int this_field_access;
 
-      next = &TREE_CHAIN (x);
+      next = &DECL_CHAIN (x);
 
       if (TREE_CODE (x) == USING_DECL)
        {
          /* Prune the access declaration from the list of fields.  */
-         *field = TREE_CHAIN (x);
+         *field = DECL_CHAIN (x);
 
          /* Save the access declarations for our caller.  */
          *access_decls = tree_cons (NULL_TREE, x, *access_decls);
@@ -3162,9 +3147,7 @@ check_field_decls (tree t, tree *access_decls,
        check_field_decl (x, t,
                          cant_have_const_ctor_p,
                          no_const_asn_ref_p,
-                         &any_default_members,
-                         cant_have_lazy_ctor_p,
-                         cant_have_lazy_opeq_p);
+                         &any_default_members);
 
       /* If any field is const, the structure type is pseudo-const.  */
       if (CP_TYPE_CONST_P (type))
@@ -3433,7 +3416,7 @@ walk_subobject_offsets (tree type,
        }
 
       /* Iterate through the fields of TYPE.  */
-      for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
+      for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
        if (TREE_CODE (field) == FIELD_DECL && !DECL_ARTIFICIAL (field))
          {
            tree field_offset;
@@ -3782,9 +3765,9 @@ build_base_field (record_layout_info rli, tree binfo,
             objects of the same type at the same address.  */
          layout_nonempty_base_or_field (rli, decl, binfo, offsets);
          /* Add the new FIELD_DECL to the list of fields for T.  */
-         TREE_CHAIN (decl) = *next_field;
+         DECL_CHAIN (decl) = *next_field;
          *next_field = decl;
-         next_field = &TREE_CHAIN (decl);
+         next_field = &DECL_CHAIN (decl);
        }
     }
   else
@@ -3896,7 +3879,7 @@ check_methods (tree t)
 {
   tree x;
 
-  for (x = TYPE_METHODS (t); x; x = TREE_CHAIN (x))
+  for (x = TYPE_METHODS (t); x; x = DECL_CHAIN (x))
     {
       check_for_override (x, t);
       if (DECL_PURE_VIRTUAL_P (x) && ! DECL_VINDEX (x))
@@ -3935,8 +3918,8 @@ build_clone (tree fn, tree name)
   /* Remember where this function came from.  */
   DECL_ABSTRACT_ORIGIN (clone) = fn;
   /* Make it easy to find the CLONE given the FN.  */
-  TREE_CHAIN (clone) = TREE_CHAIN (fn);
-  TREE_CHAIN (fn) = clone;
+  DECL_CHAIN (clone) = DECL_CHAIN (fn);
+  DECL_CHAIN (fn) = clone;
 
   /* If this is a template, do the rest on the DECL_TEMPLATE_RESULT.  */
   if (TREE_CODE (clone) == TEMPLATE_DECL)
@@ -4000,8 +3983,8 @@ build_clone (tree fn, tree name)
   /* Remove the in-charge parameter.  */
   if (DECL_HAS_IN_CHARGE_PARM_P (clone))
     {
-      TREE_CHAIN (DECL_ARGUMENTS (clone))
-       = TREE_CHAIN (TREE_CHAIN (DECL_ARGUMENTS (clone)));
+      DECL_CHAIN (DECL_ARGUMENTS (clone))
+       = DECL_CHAIN (DECL_CHAIN (DECL_ARGUMENTS (clone)));
       DECL_HAS_IN_CHARGE_PARM_P (clone) = 0;
     }
   /* And the VTT parm, in a complete [cd]tor.  */
@@ -4011,13 +3994,13 @@ build_clone (tree fn, tree name)
        DECL_HAS_VTT_PARM_P (clone) = 1;
       else
        {
-         TREE_CHAIN (DECL_ARGUMENTS (clone))
-           = TREE_CHAIN (TREE_CHAIN (DECL_ARGUMENTS (clone)));
+         DECL_CHAIN (DECL_ARGUMENTS (clone))
+           = DECL_CHAIN (DECL_CHAIN (DECL_ARGUMENTS (clone)));
          DECL_HAS_VTT_PARM_P (clone) = 0;
        }
     }
 
-  for (parms = DECL_ARGUMENTS (clone); parms; parms = TREE_CHAIN (parms))
+  for (parms = DECL_ARGUMENTS (clone); parms; parms = DECL_CHAIN (parms))
     {
       DECL_CONTEXT (parms) = clone;
       cxx_dup_lang_specific_decl (parms);
@@ -4080,8 +4063,8 @@ clone_function_decl (tree fn, int update_method_vec_p)
   tree clone;
 
   /* Avoid inappropriate cloning.  */
-  if (TREE_CHAIN (fn)
-      && DECL_CLONED_FUNCTION_P (TREE_CHAIN (fn)))
+  if (DECL_CHAIN (fn)
+      && DECL_CLONED_FUNCTION_P (DECL_CHAIN (fn)))
     return;
 
   if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (fn))
@@ -4138,8 +4121,8 @@ adjust_clone_args (tree decl)
 {
   tree clone;
 
-  for (clone = TREE_CHAIN (decl); clone && DECL_CLONED_FUNCTION_P (clone);
-       clone = TREE_CHAIN (clone))
+  for (clone = DECL_CHAIN (decl); clone && DECL_CLONED_FUNCTION_P (clone);
+       clone = DECL_CHAIN (clone))
     {
       tree orig_clone_parms = TYPE_ARG_TYPES (TREE_TYPE (clone));
       tree orig_decl_parms = TYPE_ARG_TYPES (TREE_TYPE (decl));
@@ -4410,9 +4393,9 @@ remove_zero_width_bit_fields (tree t)
             check_bitfield_decl eventually sets DECL_SIZE (*fieldsp)
             to that width.  */
          && integer_zerop (DECL_SIZE (*fieldsp)))
-       *fieldsp = TREE_CHAIN (*fieldsp);
+       *fieldsp = DECL_CHAIN (*fieldsp);
       else
-       fieldsp = &TREE_CHAIN (*fieldsp);
+       fieldsp = &DECL_CHAIN (*fieldsp);
     }
 }
 
@@ -4487,8 +4470,6 @@ check_bases_and_members (tree t)
   /* Nonzero if the implicitly generated assignment operator
      should take a non-const reference argument.  */
   int no_const_asn_ref;
-  int cant_have_lazy_ctor = 0;
-  int cant_have_lazy_opeq = 0;
   tree access_decls;
   bool saved_complex_asn_ref;
   bool saved_nontrivial_dtor;
@@ -4501,8 +4482,7 @@ check_bases_and_members (tree t)
 
   /* Check all the base-classes.  */
   check_bases (t, &cant_have_const_ctor,
-              &no_const_asn_ref, &cant_have_lazy_ctor,
-              &cant_have_lazy_opeq);
+              &no_const_asn_ref);
 
   /* Check all the method declarations.  */
   check_methods (t);
@@ -4519,9 +4499,7 @@ check_bases_and_members (tree t)
      being set appropriately.  */
   check_field_decls (t, &access_decls,
                     &cant_have_const_ctor,
-                    &no_const_asn_ref,
-                    &cant_have_lazy_ctor,
-                    &cant_have_lazy_opeq);
+                    &no_const_asn_ref);
 
   /* A nearly-empty class has to be vptr-containing; a nearly empty
      class contains just a vptr.  */
@@ -4571,7 +4549,7 @@ check_bases_and_members (tree t)
     {
       tree field;
 
-      for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field))
+      for (field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field))
        {
          tree type;
 
@@ -4593,13 +4571,11 @@ check_bases_and_members (tree t)
   /* Synthesize any needed methods.  */
   add_implicitly_declared_members (t,
                                   cant_have_const_ctor,
-                                  no_const_asn_ref,
-                                  cant_have_lazy_ctor,
-                                  cant_have_lazy_opeq);
+                                  no_const_asn_ref);
 
   /* Check defaulted declarations here so we have cant_have_const_ctor
      and don't need to worry about clones.  */
-  for (fn = TYPE_METHODS (t); fn; fn = TREE_CHAIN (fn))
+  for (fn = TYPE_METHODS (t); fn; fn = DECL_CHAIN (fn))
     if (DECL_DEFAULTED_IN_CLASS_P (fn))
       {
        int copy = copy_fn_p (fn);
@@ -4665,7 +4641,7 @@ create_vtable_ptr (tree t, tree* virtuals_p)
   tree fn;
 
   /* Collect the virtual functions declared in T.  */
-  for (fn = TYPE_METHODS (t); fn; fn = TREE_CHAIN (fn))
+  for (fn = TYPE_METHODS (t); fn; fn = DECL_CHAIN (fn))
     if (DECL_VINDEX (fn) && !DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fn)
        && TREE_CODE (DECL_VINDEX (fn)) != INTEGER_CST)
       {
@@ -4800,7 +4776,7 @@ layout_virtual_bases (record_layout_info rli, splay_tree offsets)
      bases will go after the last extant field to date.  */
   next_field = &TYPE_FIELDS (t);
   while (*next_field)
-    next_field = &TREE_CHAIN (*next_field);
+    next_field = &DECL_CHAIN (*next_field);
 
   /* Go through the virtual bases, allocating space for each virtual
      base that is not already a primary base class.  These are
@@ -5041,9 +5017,9 @@ layout_class_type (tree t, tree *virtuals_p)
   /* The vptr is always the first thing in the class.  */
   if (vptr)
     {
-      TREE_CHAIN (vptr) = TYPE_FIELDS (t);
+      DECL_CHAIN (vptr) = TYPE_FIELDS (t);
       TYPE_FIELDS (t) = vptr;
-      next_field = &TREE_CHAIN (vptr);
+      next_field = &DECL_CHAIN (vptr);
       place_field (rli, vptr);
     }
   else
@@ -5055,7 +5031,7 @@ layout_class_type (tree t, tree *virtuals_p)
   build_base_fields (rli, empty_base_offsets, next_field);
 
   /* Layout the non-static data members.  */
-  for (field = non_static_data_members; field; field = TREE_CHAIN (field))
+  for (field = non_static_data_members; field; field = DECL_CHAIN (field))
     {
       tree type;
       tree padding;
@@ -5336,7 +5312,7 @@ layout_class_type (tree t, tree *virtuals_p)
 
       /* Copy the fields from T.  */
       next_field = &TYPE_FIELDS (base_t);
-      for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field))
+      for (field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field))
        if (TREE_CODE (field) == FIELD_DECL)
          {
            *next_field = build_decl (input_location,
@@ -5349,7 +5325,7 @@ layout_class_type (tree t, tree *virtuals_p)
              = DECL_FIELD_BIT_OFFSET (field);
            DECL_SIZE (*next_field) = DECL_SIZE (field);
            DECL_MODE (*next_field) = DECL_MODE (field);
-           next_field = &TREE_CHAIN (*next_field);
+           next_field = &DECL_CHAIN (*next_field);
          }
 
       /* Record the base version of the type.  */
@@ -5396,7 +5372,7 @@ layout_class_type (tree t, tree *virtuals_p)
   warn_about_ambiguous_bases (t);
 
   /* Now that we're done with layout, give the base fields the real types.  */
-  for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field))
+  for (field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field))
     if (DECL_ARTIFICIAL (field) && IS_FAKE_BASE_TYPE (TREE_TYPE (field)))
       TREE_TYPE (field) = TYPE_CONTEXT (TREE_TYPE (field));
 
@@ -5428,7 +5404,7 @@ determine_key_method (tree type)
      key function may not be inline; those targets should not call
      this function until the end of the translation unit.  */
   for (method = TYPE_METHODS (type); method != NULL_TREE;
-       method = TREE_CHAIN (method))
+       method = DECL_CHAIN (method))
     if (DECL_VINDEX (method) != NULL_TREE
        && ! DECL_DECLARED_INLINE_P (method)
        && ! DECL_PURE_VIRTUAL_P (method))
@@ -5552,7 +5528,7 @@ finish_struct_1 (tree t)
 
   /* Complete the rtl for any static member objects of the type we're
      working on.  */
-  for (x = TYPE_FIELDS (t); x; x = TREE_CHAIN (x))
+  for (x = TYPE_FIELDS (t); x; x = DECL_CHAIN (x))
     if (TREE_CODE (x) == VAR_DECL && TREE_STATIC (x)
         && TREE_TYPE (x) != error_mark_node
        && same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (x)), t))
@@ -5649,13 +5625,13 @@ unreverse_member_declarations (tree t)
        x && TREE_CODE (x) != TYPE_DECL;
        x = next)
     {
-      next = TREE_CHAIN (x);
-      TREE_CHAIN (x) = prev;
+      next = DECL_CHAIN (x);
+      DECL_CHAIN (x) = prev;
       prev = x;
     }
   if (prev)
     {
-      TREE_CHAIN (TYPE_FIELDS (t)) = x;
+      DECL_CHAIN (TYPE_FIELDS (t)) = x;
       if (prev)
        TYPE_FIELDS (t) = prev;
     }
@@ -5692,7 +5668,7 @@ finish_struct (tree t, tree attributes)
         CLASSTYPE_PURE_VIRTUALS contains the list of the inline friends
         (see CLASSTYPE_INLINE_FRIENDS) so we need to clear it.  */
       CLASSTYPE_PURE_VIRTUALS (t) = NULL;
-      for (x = TYPE_METHODS (t); x; x = TREE_CHAIN (x))
+      for (x = TYPE_METHODS (t); x; x = DECL_CHAIN (x))
        if (DECL_PURE_VIRTUAL_P (x))
          VEC_safe_push (tree, gc, CLASSTYPE_PURE_VIRTUALS (t), x);
       complete_vars (t);
@@ -6505,7 +6481,7 @@ resolve_address_of_overloaded_function (tree target_type,
     }
 
   if (TYPE_PTRFN_P (target_type) || TYPE_PTRMEMFUNC_P (target_type))
-    return cp_build_unary_op (ADDR_EXPR, fn, 0, flags);
+    return cp_build_addr_expr (fn, flags);
   else
     {
       /* The target must be a REFERENCE_TYPE.  Above, cp_build_unary_op
@@ -6792,7 +6768,7 @@ is_really_empty_class (tree type)
           BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i)
        if (!is_really_empty_class (BINFO_TYPE (base_binfo)))
          return false;
-      for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
+      for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field))
        if (TREE_CODE (field) == FIELD_DECL
            && !DECL_ARTIFICIAL (field)
            && !is_really_empty_class (TREE_TYPE (field)))
@@ -6848,7 +6824,13 @@ note_name_declared_in_class (tree name, tree decl)
     = current_class_stack[current_class_depth - 1].names_used;
   if (!names_used)
     return;
-
+  /* The C language allows members to be declared with a type of the same
+     name, and the C++ standard says this diagnostic is not required.  So
+     allow it in extern "C" blocks unless predantic is specified.
+     Allow it in all cases if -ms-extensions is specified.  */
+  if ((!pedantic && current_lang_name == lang_name_c)
+      || flag_ms_extensions)
+    return;
   n = splay_tree_lookup (names_used, (splay_tree_key) name);
   if (n)
     {
@@ -7245,8 +7227,8 @@ build_vtt (tree t)
   vtt = build_vtable (t, mangle_vtt_for_type (t), type);
   initialize_artificial_var (vtt, inits);
   /* Add the VTT to the vtables list.  */
-  TREE_CHAIN (vtt) = TREE_CHAIN (CLASSTYPE_VTABLES (t));
-  TREE_CHAIN (CLASSTYPE_VTABLES (t)) = vtt;
+  DECL_CHAIN (vtt) = DECL_CHAIN (CLASSTYPE_VTABLES (t));
+  DECL_CHAIN (CLASSTYPE_VTABLES (t)) = vtt;
 
   dump_vtt (t, vtt);
 }
@@ -7831,9 +7813,14 @@ build_vtbl_initializer (tree binfo,
          if (DECL_PURE_VIRTUAL_P (fn_original))
            {
              fn = abort_fndecl;
-             if (abort_fndecl_addr == NULL)
-               abort_fndecl_addr = build1 (ADDR_EXPR, vfunc_ptr_type_node, fn);
-             init = abort_fndecl_addr;
+             if (!TARGET_VTABLE_USES_DESCRIPTORS)
+               {
+                 if (abort_fndecl_addr == NULL)
+                   abort_fndecl_addr
+                     = fold_convert (vfunc_ptr_type_node,
+                                     build_fold_addr_expr (fn));
+                 init = abort_fndecl_addr;
+               }
            }
          else
            {
@@ -7845,7 +7832,9 @@ build_vtbl_initializer (tree binfo,
                }
              /* Take the address of the function, considering it to be of an
                 appropriate generic type.  */
-             init = build1 (ADDR_EXPR, vfunc_ptr_type_node, fn);
+             if (!TARGET_VTABLE_USES_DESCRIPTORS)
+               init = fold_convert (vfunc_ptr_type_node,
+                                    build_fold_addr_expr (fn));
            }
        }
 
@@ -7860,8 +7849,7 @@ build_vtbl_initializer (tree binfo,
            for (i = 0; i < TARGET_VTABLE_USES_DESCRIPTORS; ++i)
              {
                tree fdesc = build2 (FDESC_EXPR, vfunc_ptr_type_node,
-                                    TREE_OPERAND (init, 0),
-                                    build_int_cst (NULL_TREE, i));
+                                    fn, build_int_cst (NULL_TREE, i));
                TREE_CONSTANT (fdesc) = 1;
 
                CONSTRUCTOR_APPEND_ELT (*inits, NULL_TREE, fdesc);
@@ -8076,7 +8064,7 @@ add_vcall_offset_vtbl_entries_1 (tree binfo, vtbl_init_data* vid)
         order.  G++ 3.2 used the order in the vtable.  */
       for (orig_fn = TYPE_METHODS (BINFO_TYPE (binfo));
           orig_fn;
-          orig_fn = TREE_CHAIN (orig_fn))
+          orig_fn = DECL_CHAIN (orig_fn))
        if (DECL_VINDEX (orig_fn))
          add_vcall_offset (orig_fn, binfo, vid);
     }
@@ -8160,7 +8148,7 @@ add_vcall_offset (tree orig_fn, tree binfo, vtbl_init_data *vid)
      signature as FN, then we do not need a second vcall offset.
      Check the list of functions already present in the derived
      class vtable.  */
-  for (i = 0; VEC_iterate (tree, vid->fns, i, derived_entry); ++i)
+  FOR_EACH_VEC_ELT (tree, vid->fns, i, derived_entry)
     {
       if (same_signature_p (derived_entry, orig_fn)
          /* We only use one vcall offset for virtual destructors,
This page took 0.057289 seconds and 5 git commands to generate.