call.c (build_user_type_conversion_1): Use OVL_FIRST.
authorNathan Sidwell <nathan@acm.org>
Tue, 16 May 2017 17:36:03 +0000 (17:36 +0000)
committerNathan Sidwell <nathan@gcc.gnu.org>
Tue, 16 May 2017 17:36:03 +0000 (17:36 +0000)
* call.c (build_user_type_conversion_1): Use OVL_FIRST.
(print_error_for_call_faulure): Use OVL_NAME.
(build_op_call_1): Use ovl_iterator.
(add_candidates): Use OVL_FIRST & lkp_iterator.
(build_op_delete_call): Use MAYBE_BASELINK_FUNCTIONS &
lkp_iterator.
* class.c (deduce_noexcept_on_destructors): Use ovl_iterator.
(type_has_user_nondefault_constructor)
in_class_defaulted_default_constructor,
type_has_user_provided_constructor,
type_has_user_provided_or_explicit_constructor,
type_has_non_user_provided_default_constructor,
vbase_has_user_provided_move_assign,
type_has_move_constructor, type_has_move_assign,
type_has_user_declared_move_constructor,
type_has_user_declared_move_assign,
type_build_ctor_call, type_build_dtor_call,
type_requires_array_cookie, explain_non_literal_class): Likewise.
(finish_struct): Use lkp_iterator.
(resolve_address_of_overloaded_function): Use OVL_NAME,
lkp_iterator.
(note_name_declared_in_class): Use OVL_NAME.
* cxx-pretty-print.c (pp_cxx_unqualified_id): Use OVL_FIRST.
(pp_cxx_qualified_id, cxx_pretty_printer::id_expression)
cxx_pretty_printer::expression): Likewise.
* decl2.c (check_classfn): Use ovl_iterator.
* pt.c (retrieve_specialization): Use ovl_iterator.
* tree.c (cp_tree_equal): Use lkp_iterator.
(type_has_nontrivial_copy_init): Use ovl_iterator.
((--This line, and those below, will be ignored--

M    cp/ChangeLog
M    cp/call.c
M    cp/class.c
M    cp/pt.c
M    cp/decl2.c
M    cp/tree.c
M    cp/cxx-pretty-print.c

From-SVN: r248120

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/class.c
gcc/cp/cxx-pretty-print.c
gcc/cp/decl2.c
gcc/cp/pt.c
gcc/cp/tree.c

index 06bc8b6..4d508ec 100644 (file)
@@ -1,5 +1,34 @@
 2017-05-16  Nathan Sidwell  <nathan@acm.org>
 
+       * call.c (build_user_type_conversion_1): Use OVL_FIRST.
+       (print_error_for_call_faulure): Use OVL_NAME.
+       (build_op_call_1): Use ovl_iterator.
+       (add_candidates): Use OVL_FIRST & lkp_iterator.
+       (build_op_delete_call): Use MAYBE_BASELINK_FUNCTIONS &
+       lkp_iterator.
+       * class.c (deduce_noexcept_on_destructors): Use ovl_iterator.
+       (type_has_user_nondefault_constructor,
+       in_class_defaulted_default_constructor,
+       type_has_user_provided_constructor,
+       type_has_user_provided_or_explicit_constructor,
+       type_has_non_user_provided_default_constructor,
+       vbase_has_user_provided_move_assign,
+       type_has_move_constructor, type_has_move_assign,
+       type_has_user_declared_move_constructor,
+       type_has_user_declared_move_assign,
+       type_build_ctor_call, type_build_dtor_call,
+       type_requires_array_cookie, explain_non_literal_class): Likewise.
+       (finish_struct): Use lkp_iterator.
+       (resolve_address_of_overloaded_function): Use OVL_NAME, lkp_iterator.
+       (note_name_declared_in_class): Use OVL_NAME.
+       * cxx-pretty-print.c (pp_cxx_unqualified_id): Use OVL_FIRST.
+       (pp_cxx_qualified_id, cxx_pretty_printer::id_expression,
+       cxx_pretty_printer::expression): Likewise.
+       * decl2.c (check_classfn): Use ovl_iterator.
+       * pt.c (retrieve_specialization): Use ovl_iterator.
+       * tree.c (cp_tree_equal): Use lkp_iterator.
+       (type_has_nontrivial_copy_init): Use ovl_iterator.
+
        * typeck2.c (cxx_incomplete_type_diagnostic): Revert change and
        check is_overloaded_fn.
 
index b9807cf..1367344 100644 (file)
@@ -3783,8 +3783,8 @@ build_user_type_conversion_1 (tree totype, tree expr, int flags,
 
       /* We should never try to call the abstract or base constructor
         from here.  */
-      gcc_assert (!DECL_HAS_IN_CHARGE_PARM_P (OVL_CURRENT (ctors))
-                 && !DECL_HAS_VTT_PARM_P (OVL_CURRENT (ctors)));
+      gcc_assert (!DECL_HAS_IN_CHARGE_PARM_P (OVL_FIRST (ctors))
+                 && !DECL_HAS_VTT_PARM_P (OVL_FIRST (ctors)));
 
       args = make_tree_vector_single (expr);
       if (BRACE_ENCLOSED_INITIALIZER_P (expr))
@@ -4172,7 +4172,7 @@ print_error_for_call_failure (tree fn, vec<tree, va_gc> *args,
       targs = TREE_OPERAND (fn, 1);
       fn = TREE_OPERAND (fn, 0);
     }
-  tree name = DECL_NAME (OVL_CURRENT (fn));
+  tree name = OVL_NAME (fn);
   location_t loc = location_of (name);
   if (targs)
     name = lookup_template_function (name, targs);
@@ -4449,16 +4449,15 @@ build_op_call_1 (tree obj, vec<tree, va_gc> **args, tsubst_flags_t complain)
 
   for (; convs; convs = TREE_CHAIN (convs))
     {
-      tree fns = TREE_VALUE (convs);
       tree totype = TREE_TYPE (convs);
 
       if (TYPE_PTRFN_P (totype)
          || TYPE_REFFN_P (totype)
          || (TREE_CODE (totype) == REFERENCE_TYPE
              && TYPE_PTRFN_P (TREE_TYPE (totype))))
-       for (; fns; fns = OVL_NEXT (fns))
+       for (ovl_iterator iter (TREE_VALUE (convs)); iter; ++iter)
          {
-           tree fn = OVL_CURRENT (fns);
+           tree fn = *iter;
 
            if (DECL_NONCONVERTING_P (fn))
              continue;
@@ -5376,13 +5375,12 @@ add_candidates (tree fns, tree first_arg, const vec<tree, va_gc> *args,
   bool check_list_ctor;
   bool check_converting;
   unification_kind_t strict;
-  tree fn;
 
   if (!fns)
     return;
 
   /* Precalculate special handling of constructors and conversion ops.  */
-  fn = OVL_CURRENT (fns);
+  tree fn = OVL_FIRST (fns);
   if (DECL_CONV_FN_P (fn))
     {
       check_list_ctor = false;
@@ -5425,12 +5423,12 @@ add_candidates (tree fns, tree first_arg, const vec<tree, va_gc> *args,
     /* Delay creating the implicit this parameter until it is needed.  */
     non_static_args = NULL;
 
-  for (; fns; fns = OVL_NEXT (fns))
+  for (lkp_iterator iter (fns); iter; ++iter)
     {
       tree fn_first_arg;
       const vec<tree, va_gc> *fn_args;
 
-      fn = OVL_CURRENT (fns);
+      fn = *iter;
 
       if (check_converting && DECL_NONCONVERTING_P (fn))
        continue;
@@ -6201,8 +6199,7 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
       if (fn == error_mark_node)
        return NULL_TREE;
 
-      if (BASELINK_P (fn))
-       fn = BASELINK_FUNCTIONS (fn);
+      fn = MAYBE_BASELINK_FUNCTIONS (fn);
 
       /* "If the lookup finds the two-parameter form of a usual deallocation
         function (3.7.4.2) and that function, considered as a placement
@@ -6221,10 +6218,10 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
             the usual deallocation function, so we shouldn't complain
             about using the operator delete (void *, size_t).  */
          if (DECL_CLASS_SCOPE_P (fn))
-           for (t = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns;
-                t; t = OVL_NEXT (t))
+           for (lkp_iterator iter (MAYBE_BASELINK_FUNCTIONS (fns));
+                iter; ++iter)
              {
-               tree elt = OVL_CURRENT (t);
+               tree elt = *iter;
                if (usual_deallocation_fn_p (elt)
                    && FUNCTION_ARG_CHAIN (elt) == void_list_node)
                  goto ok;
@@ -6263,10 +6260,9 @@ build_op_delete_call (enum tree_code code, tree addr, tree size,
        allocation function. If the lookup finds a single matching
        deallocation function, that function will be called; otherwise, no
        deallocation function will be called."  */
-    for (t = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns;
-        t; t = OVL_NEXT (t))
+    for (lkp_iterator iter (MAYBE_BASELINK_FUNCTIONS (fns)); iter; ++iter)
       {
-       tree elt = OVL_CURRENT (t);
+       tree elt = *iter;
        if (usual_deallocation_fn_p (elt))
          {
            if (!fn)
index 15b583a..6726a6f 100644 (file)
@@ -5069,8 +5069,8 @@ deduce_noexcept_on_destructors (tree t)
   if (!CLASSTYPE_METHOD_VEC (t))
     return;
 
-  for (tree fns = CLASSTYPE_DESTRUCTORS (t); fns; fns = OVL_NEXT (fns))
-    deduce_noexcept_on_destructor (OVL_CURRENT (fns));
+  for (ovl_iterator iter (CLASSTYPE_DESTRUCTORS (t)); iter; ++iter)
+    deduce_noexcept_on_destructor (*iter);
 }
 
 /* Subroutine of set_one_vmethod_tm_attributes.  Search base classes
@@ -5230,14 +5230,12 @@ default_ctor_p (tree fn)
 bool
 type_has_user_nondefault_constructor (tree t)
 {
-  tree fns;
-
   if (!TYPE_HAS_USER_CONSTRUCTOR (t))
     return false;
 
-  for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns))
+  for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
     {
-      tree fn = OVL_CURRENT (fns);
+      tree fn = *iter;
       if (!DECL_ARTIFICIAL (fn)
          && (TREE_CODE (fn) == TEMPLATE_DECL
              || (skip_artificial_parms_for (fn, DECL_ARGUMENTS (fn))
@@ -5257,9 +5255,9 @@ in_class_defaulted_default_constructor (tree t)
   if (!TYPE_HAS_USER_CONSTRUCTOR (t))
     return NULL_TREE;
 
-  for (tree fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns))
+  for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
     {
-      tree fn = OVL_CURRENT (fns);
+      tree fn = *iter;
 
       if (DECL_DEFAULTED_IN_CLASS_P (fn)
          && default_ctor_p (fn))
@@ -5288,8 +5286,6 @@ user_provided_p (tree fn)
 bool
 type_has_user_provided_constructor (tree t)
 {
-  tree fns;
-
   if (!CLASS_TYPE_P (t))
     return false;
 
@@ -5300,8 +5296,8 @@ type_has_user_provided_constructor (tree t)
   if (!CLASSTYPE_METHOD_VEC (t))
     return false;
 
-  for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns))
-    if (user_provided_p (OVL_CURRENT (fns)))
+  for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
+    if (user_provided_p (*iter))
       return true;
 
   return false;
@@ -5312,8 +5308,6 @@ type_has_user_provided_constructor (tree t)
 bool
 type_has_user_provided_or_explicit_constructor (tree t)
 {
-  tree fns;
-
   if (!CLASS_TYPE_P (t))
     return false;
 
@@ -5324,9 +5318,9 @@ type_has_user_provided_or_explicit_constructor (tree t)
   if (!CLASSTYPE_METHOD_VEC (t))
     return false;
 
-  for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns))
+  for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
     {
-      tree fn = OVL_CURRENT (fns);
+      tree fn = *iter;
       if (user_provided_p (fn) || DECL_NONCONVERTING_P (fn))
        return true;
     }
@@ -5341,16 +5335,14 @@ type_has_user_provided_or_explicit_constructor (tree t)
 bool
 type_has_non_user_provided_default_constructor (tree t)
 {
-  tree fns;
-
   if (!TYPE_HAS_DEFAULT_CONSTRUCTOR (t))
     return false;
   if (CLASSTYPE_LAZY_DEFAULT_CTOR (t))
     return true;
 
-  for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns))
+  for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
     {
-      tree fn = OVL_CURRENT (fns);
+      tree fn = *iter;
       if (TREE_CODE (fn) == FUNCTION_DECL
          && default_ctor_p (fn)
          && !user_provided_p (fn))
@@ -5369,11 +5361,11 @@ bool
 vbase_has_user_provided_move_assign (tree type)
 {
   /* Does the type itself have a user-provided move assignment operator?  */
-  for (tree fns
-        = lookup_fnfields_slot_nolazy (type, cp_assignment_operator_id (NOP_EXPR));
-       fns; fns = OVL_NEXT (fns))
+  for (ovl_iterator iter (lookup_fnfields_slot_nolazy
+                         (type, cp_assignment_operator_id (NOP_EXPR)));
+       iter; ++iter)
     {
-      tree fn = OVL_CURRENT (fns);
+      tree fn = *iter;
       if (move_fn_p (fn) && user_provided_p (fn))
        return true;
     }
@@ -5503,8 +5495,6 @@ type_has_virtual_destructor (tree type)
 bool
 type_has_move_constructor (tree t)
 {
-  tree fns;
-
   if (CLASSTYPE_LAZY_MOVE_CTOR (t))
     {
       gcc_assert (COMPLETE_TYPE_P (t));
@@ -5514,8 +5504,8 @@ type_has_move_constructor (tree t)
   if (!CLASSTYPE_METHOD_VEC (t))
     return false;
 
-  for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns))
-    if (move_fn_p (OVL_CURRENT (fns)))
+  for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
+    if (move_fn_p (*iter))
       return true;
 
   return false;
@@ -5526,17 +5516,16 @@ type_has_move_constructor (tree t)
 bool
 type_has_move_assign (tree t)
 {
-  tree fns;
-
   if (CLASSTYPE_LAZY_MOVE_ASSIGN (t))
     {
       gcc_assert (COMPLETE_TYPE_P (t));
       lazily_declare_fn (sfk_move_assignment, t);
     }
 
-  for (fns = lookup_fnfields_slot_nolazy (t, cp_assignment_operator_id (NOP_EXPR));
-       fns; fns = OVL_NEXT (fns))
-    if (move_fn_p (OVL_CURRENT (fns)))
+  for (ovl_iterator iter (lookup_fnfields_slot_nolazy
+                         (t, cp_assignment_operator_id (NOP_EXPR)));
+       iter; ++iter)
+    if (move_fn_p (*iter))
       return true;
 
   return false;
@@ -5550,17 +5539,15 @@ type_has_move_assign (tree t)
 bool
 type_has_user_declared_move_constructor (tree t)
 {
-  tree fns;
-
   if (CLASSTYPE_LAZY_MOVE_CTOR (t))
     return false;
 
   if (!CLASSTYPE_METHOD_VEC (t))
     return false;
 
-  for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns))
+  for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
     {
-      tree fn = OVL_CURRENT (fns);
+      tree fn = *iter;
       if (move_fn_p (fn) && !DECL_ARTIFICIAL (fn))
        return true;
     }
@@ -5574,15 +5561,14 @@ type_has_user_declared_move_constructor (tree t)
 bool
 type_has_user_declared_move_assign (tree t)
 {
-  tree fns;
-
   if (CLASSTYPE_LAZY_MOVE_ASSIGN (t))
     return false;
 
-  for (fns = lookup_fnfields_slot_nolazy (t, cp_assignment_operator_id (NOP_EXPR));
-       fns; fns = OVL_NEXT (fns))
+  for (ovl_iterator iter (lookup_fnfields_slot_nolazy
+                         (t, cp_assignment_operator_id (NOP_EXPR)));
+       iter; ++iter)
     {
-      tree fn = OVL_CURRENT (fns);
+      tree fn = *iter;
       if (move_fn_p (fn) && !DECL_ARTIFICIAL (fn))
        return true;
     }
@@ -5615,10 +5601,11 @@ type_build_ctor_call (tree t)
     return false;
   /* A user-declared constructor might be private, and a constructor might
      be trivial but deleted.  */
-  for (tree fns = lookup_fnfields_slot (inner, complete_ctor_identifier);
-       fns; fns = OVL_NEXT (fns))
+  for (ovl_iterator iter
+        (lookup_fnfields_slot (inner, complete_ctor_identifier));
+       iter; ++iter)
     {
-      tree fn = OVL_CURRENT (fns);
+      tree fn = *iter;
       if (!DECL_ARTIFICIAL (fn)
          || DECL_DELETED_FN (fn))
        return true;
@@ -5642,10 +5629,11 @@ type_build_dtor_call (tree t)
     return false;
   /* A user-declared destructor might be private, and a destructor might
      be trivial but deleted.  */
-  for (tree fns = lookup_fnfields_slot (inner, complete_dtor_identifier);
-       fns; fns = OVL_NEXT (fns))
+  for (ovl_iterator iter
+        (lookup_fnfields_slot (inner, complete_dtor_identifier));
+       iter; ++iter)
     {
-      tree fn = OVL_CURRENT (fns);
+      tree fn = *iter;
       if (!DECL_ARTIFICIAL (fn)
          || DECL_DELETED_FN (fn))
        return true;
@@ -5707,16 +5695,13 @@ type_requires_array_cookie (tree type)
   if (!fns || fns == error_mark_node)
     return false;
   /* Loop through all of the functions.  */
-  for (fns = BASELINK_FUNCTIONS (fns); fns; fns = OVL_NEXT (fns))
+  for (lkp_iterator iter (BASELINK_FUNCTIONS (fns)); iter; ++iter)
     {
-      tree fn;
-      tree second_parm;
+      tree fn = *iter;
 
-      /* Select the current function.  */
-      fn = OVL_CURRENT (fns);
       /* See if this function is a one-argument delete function.  If
         it is, then it will be the usual deallocation function.  */
-      second_parm = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (fn)));
+      tree second_parm = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (fn)));
       if (second_parm == void_list_node)
        return false;
       /* Do not consider this function if its second argument is an
@@ -5808,26 +5793,23 @@ explain_non_literal_class (tree t)
              "default constructor, and has no constexpr constructor that "
              "is not a copy or move constructor", t);
       if (type_has_non_user_provided_default_constructor (t))
-       {
-         /* Note that we can't simply call locate_ctor because when the
-            constructor is deleted it just returns NULL_TREE.  */
-         tree fns;
-         for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns))
-           {
-             tree fn = OVL_CURRENT (fns);
-             tree parms = TYPE_ARG_TYPES (TREE_TYPE (fn));
+       /* Note that we can't simply call locate_ctor because when the
+          constructor is deleted it just returns NULL_TREE.  */
+       for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
+         {
+           tree fn = *iter;
+           tree parms = TYPE_ARG_TYPES (TREE_TYPE (fn));
 
-             parms = skip_artificial_parms_for (fn, parms);
+           parms = skip_artificial_parms_for (fn, parms);
 
-             if (sufficient_parms_p (parms))
-               {
-                 if (DECL_DELETED_FN (fn))
-                   maybe_explain_implicit_delete (fn);
-                 else
-                   explain_invalid_constexpr_fn (fn);
-                 break;
-               }
-           }
+           if (sufficient_parms_p (parms))
+             {
+               if (DECL_DELETED_FN (fn))
+                 maybe_explain_implicit_delete (fn);
+               else
+                 explain_invalid_constexpr_fn (fn);
+               break;
+             }
        }
     }
   else
@@ -7508,8 +7490,8 @@ finish_struct (tree t, tree attributes)
          {
            tree fn = strip_using_decl (x);
            if (is_overloaded_fn (fn))
-             for (; fn; fn = OVL_NEXT (fn))
-               add_method (t, OVL_CURRENT (fn), x);
+             for (lkp_iterator iter (fn); iter; ++iter)
+               add_method (t, *iter, true);
          }
 
       /* Remember current #pragma pack value.  */
@@ -8165,7 +8147,7 @@ resolve_address_of_overloaded_function (tree target_type,
       if (complain & tf_error)
        error ("cannot resolve overloaded function %qD based on"
               " conversion to type %qT",
-              DECL_NAME (OVL_FUNCTION (overload)), target_type);
+              OVL_NAME (overload), target_type);
       return error_mark_node;
     }
 
@@ -8183,9 +8165,9 @@ resolve_address_of_overloaded_function (tree target_type,
      if we're just going to throw them out anyhow.  But, of course, we
      can only do this when we don't *need* a template function.  */
   if (!template_only)
-    for (tree fns = overload; fns; fns = OVL_NEXT (fns))
+    for (lkp_iterator iter (overload); iter; ++iter)
       {
-       tree fn = OVL_CURRENT (fns);
+       tree fn = *iter;
 
        if (TREE_CODE (fn) == TEMPLATE_DECL)
          /* We're not looking for templates just yet.  */
@@ -8214,7 +8196,6 @@ resolve_address_of_overloaded_function (tree target_type,
     {
       tree target_arg_types;
       tree target_ret_type;
-      tree fns;
       tree *args;
       unsigned int nargs, ia;
       tree arg;
@@ -8230,9 +8211,9 @@ resolve_address_of_overloaded_function (tree target_type,
        args[ia] = TREE_VALUE (arg);
       nargs = ia;
 
-      for (fns = overload; fns; fns = OVL_NEXT (fns))
+      for (lkp_iterator iter (overload); iter; ++iter)
        {
-         tree fn = OVL_CURRENT (fns);
+         tree fn = *iter;
          tree instantiation;
          tree targs;
 
@@ -8309,8 +8290,7 @@ resolve_address_of_overloaded_function (tree target_type,
       if (complain & tf_error)
        {
          error ("no matches converting function %qD to type %q#T",
-                DECL_NAME (OVL_CURRENT (overload)),
-                target_type);
+                OVL_NAME (overload), target_type);
 
          print_candidates (overload);
        }
@@ -8337,8 +8317,7 @@ resolve_address_of_overloaded_function (tree target_type,
          if (complain & tf_error)
            {
              error ("converting overloaded function %qD to type %q#T is ambiguous",
-                    DECL_NAME (OVL_FUNCTION (overload)),
-                    target_type);
+                    OVL_NAME (overload), target_type);
 
              /* Since print_candidates expects the functions in the
                 TREE_VALUE slot, we flip them here.  */
@@ -8750,7 +8729,7 @@ note_name_declared_in_class (tree name, tree decl)
       permerror (input_location, "declaration of %q#D", decl);
       permerror (location_of ((tree) n->value),
                 "changes meaning of %qD from %q#D",
-                DECL_NAME (OVL_CURRENT (decl)), (tree) n->value);
+                OVL_NAME (decl), (tree) n->value);
     }
 }
 
index f76c30a..e92a72a 100644 (file)
@@ -141,7 +141,7 @@ pp_cxx_unqualified_id (cxx_pretty_printer *pp, tree t)
       break;
 
     case OVERLOAD:
-      t = OVL_CURRENT (t);
+      t = OVL_FIRST (t);
       /* FALLTHRU */
     case VAR_DECL:
     case PARM_DECL:
@@ -281,7 +281,7 @@ pp_cxx_qualified_id (cxx_pretty_printer *pp, tree t)
         FIXME:  This is probably the wrong pretty-printing for conversion
         functions and some function templates.  */
     case OVERLOAD:
-      t = OVL_CURRENT (t);
+      t = OVL_FIRST (t);
       /* FALLTHRU */
     case FUNCTION_DECL:
       if (DECL_FUNCTION_MEMBER_P (t))
@@ -350,7 +350,7 @@ void
 cxx_pretty_printer::id_expression (tree t)
 {
   if (TREE_CODE (t) == OVERLOAD)
-    t = OVL_CURRENT (t);
+    t = OVL_FIRST (t);
   if (DECL_P (t) && DECL_CONTEXT (t))
     pp_cxx_qualified_id (this, t);
   else
@@ -1066,7 +1066,7 @@ cxx_pretty_printer::expression (tree t)
       break;
 
     case OVERLOAD:
-      t = OVL_CURRENT (t);
+      t = OVL_FIRST (t);
       /* FALLTHRU */
     case VAR_DECL:
     case PARM_DECL:
index c1ac980..3e88154 100644 (file)
@@ -608,18 +608,12 @@ check_classfn (tree ctype, tree function, tree template_parms)
   if (ix >= 0)
     {
       vec<tree, va_gc> *methods = CLASSTYPE_METHOD_VEC (ctype);
-      tree fndecls, fndecl = 0;
-      bool is_conv_op;
-      const char *format = NULL;
 
-      for (fndecls = (*methods)[ix];
-          fndecls; fndecls = OVL_NEXT (fndecls))
+      for (ovl_iterator iter ((*methods)[ix]); iter; ++iter)
        {
-         tree p1, p2;
-
-         fndecl = OVL_CURRENT (fndecls);
-         p1 = TYPE_ARG_TYPES (TREE_TYPE (function));
-         p2 = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
+         tree fndecl = *iter;
+         tree p1 = TYPE_ARG_TYPES (TREE_TYPE (function));
+         tree p2 = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
 
          /* We cannot simply call decls_match because this doesn't
             work for static member functions that are pretending to
@@ -662,49 +656,47 @@ check_classfn (tree ctype, tree function, tree template_parms)
              && (!DECL_TEMPLATE_SPECIALIZATION (function)
                  || (DECL_TI_TEMPLATE (function)
                      == DECL_TI_TEMPLATE (fndecl))))
-           break;
-       }
-      if (fndecls)
-       {
-         if (pushed_scope)
-           pop_scope (pushed_scope);
-         return OVL_CURRENT (fndecls);
+           {
+             if (pushed_scope)
+               pop_scope (pushed_scope);
+             return fndecl;
+           }
        }
-      
+
       error_at (DECL_SOURCE_LOCATION (function),
                "prototype for %q#D does not match any in class %qT",
                function, ctype);
-      is_conv_op = DECL_CONV_FN_P (fndecl);
+
+      const char *format = NULL;
+      tree first = OVL_FIRST ((*methods)[ix]);
+      bool is_conv_op = DECL_CONV_FN_P (first);
+      tree prev = NULL_TREE;
 
       if (is_conv_op)
        ix = CLASSTYPE_FIRST_CONVERSION_SLOT;
-      fndecls = (*methods)[ix];
-      while (fndecls)
+      do
        {
-         fndecl = OVL_CURRENT (fndecls);
-         fndecls = OVL_NEXT (fndecls);
-
-         if (!fndecls && is_conv_op)
+         ovl_iterator iter ((*methods)[ix++]);
+         if (is_conv_op && !DECL_CONV_FN_P (*iter))
+           break;
+         for (; iter; ++iter)
            {
-             if (methods->length () > (size_t) ++ix)
+             if (prev)
                {
-                 fndecls = (*methods)[ix];
-                 if (!DECL_CONV_FN_P (OVL_CURRENT (fndecls)))
-                   {
-                     fndecls = NULL_TREE;
-                     is_conv_op = false;
-                   }
+                 if (!format)
+                   format = N_("candidates are: %+#D");
+                 error (format, prev);
+                 format = "                %+#D";
                }
-             else
-               is_conv_op = false;
+             prev = *iter;
            }
-         if (format)
-           format = "                %+#D";
-         else if (fndecls)
-           format = N_("candidates are: %+#D");
-         else
+       }
+      while (is_conv_op && size_t (ix) < methods->length ());
+      if (prev)
+       {
+         if (!format)
            format = N_("candidate is: %+#D");
-         error (format, fndecl);
+         error (format, prev);
        }
     }
   else if (!COMPLETE_TYPE_P (ctype))
index 142ed66..5fc47ab 100644 (file)
@@ -1187,31 +1187,25 @@ retrieve_specialization (tree tmpl, tree args, hashval_t hash)
 
   if (optimize_specialization_lookup_p (tmpl))
     {
-      tree class_template;
-      tree class_specialization;
-      vec<tree, va_gc> *methods;
-      tree fns;
-      int idx;
-
       /* The template arguments actually apply to the containing
         class.  Find the class specialization with those
         arguments.  */
-      class_template = CLASSTYPE_TI_TEMPLATE (DECL_CONTEXT (tmpl));
-      class_specialization
+      tree class_template = CLASSTYPE_TI_TEMPLATE (DECL_CONTEXT (tmpl));
+      tree class_specialization
        = retrieve_specialization (class_template, args, 0);
       if (!class_specialization)
        return NULL_TREE;
       /* Now, find the appropriate entry in the CLASSTYPE_METHOD_VEC
         for the specialization.  */
-      idx = class_method_index_for_fn (class_specialization, tmpl);
+      int idx = class_method_index_for_fn (class_specialization, tmpl);
       if (idx == -1)
        return NULL_TREE;
       /* Iterate through the methods with the indicated name, looking
         for the one that has an instance of TMPL.  */
-      methods = CLASSTYPE_METHOD_VEC (class_specialization);
-      for (fns = (*methods)[idx]; fns; fns = OVL_NEXT (fns))
+      vec<tree, va_gc> *methods = CLASSTYPE_METHOD_VEC (class_specialization);
+      for (ovl_iterator iter ((*methods)[idx]); iter; ++iter)
        {
-         tree fn = OVL_CURRENT (fns);
+         tree fn = *iter;
          if (DECL_TEMPLATE_INFO (fn) && DECL_TI_TEMPLATE (fn) == tmpl
              /* using-declarations can add base methods to the method vec,
                 and we don't want those here.  */
index 7b62173..83dd7a3 100644 (file)
@@ -3403,9 +3403,16 @@ cp_tree_equal (tree t1, tree t2)
       return same_type_p (PTRMEM_CST_CLASS (t1), PTRMEM_CST_CLASS (t2));
 
     case OVERLOAD:
-      if (OVL_FUNCTION (t1) != OVL_FUNCTION (t2))
-       return false;
-      return cp_tree_equal (OVL_CHAIN (t1), OVL_CHAIN (t2));
+      {
+       /* Two overloads. Must be exactly the same set of decls.  */
+       lkp_iterator first (t1);
+       lkp_iterator second (t2);
+
+       for (; first && second; ++first, ++second)
+         if (*first != *second)
+           return false;
+       return !(first || second);
+      }
 
     case TRAIT_EXPR:
       if (TRAIT_EXPR_KIND (t1) != TRAIT_EXPR_KIND (t2))
@@ -3682,9 +3689,9 @@ type_has_nontrivial_copy_init (const_tree type)
        }
 
       if (!saw_non_deleted && CLASSTYPE_METHOD_VEC (t))
-       for (tree fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns))
+       for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter)
          {
-           tree fn = OVL_CURRENT (fns);
+           tree fn = *iter;
            if (copy_fn_p (fn))
              {
                saw_copy = true;