]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
* cp-tree.h (OVL_FIRST, OVL_NAME): New.
authornathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 May 2017 13:15:53 +0000 (13:15 +0000)
committernathan <nathan@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 16 May 2017 13:15:53 +0000 (13:15 +0000)
(ovl_first): New.
* constexpr.c (function_concept_check): Use OVL_FIRST.
* cvt.c (build_expr_type_conversion): Likewise.
* decl.c (poplevel, grokdeclarator): Use OVL_NAME.
* decl2.c (mark_used): Use OVL_FIRST.
* error.c (dump_decl): Use OVL_FIRST, OVL_NAME.
(dump_expr, location_of): Use OVL_FIRST.
* friend.c (do_friend): Use OVL_NAME.
* init.c (build_offset_ref): Use OVL_FIRST.
* mangle.c (write_member_name): Likewise.
(write_expression): Use OVL_NAME.
* method.c (strip_inheriting_ctors): Use OVL_FIRST.
* name-lookup.c (pushdecl_class_level): Use OVL_NAME.
* pt.c (check_explicit_specialization): Use OVL_FIRST.
(check_template_shadow): Likewise.
(tsubst_template_args): Use OVL_NAME.
(tsubst_baselink): Use OVL_FIRST.
* semantics.c (perform_koenig_lookup): Use OVL_NAME.
* tree.c (get_first_fn): Use OVL_FIRST.
* typeck.c (finish_class_member_access_expr): Use OVL_NAME.
(cp_build_addr_expr_1): Use OVL_FIRST.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@248108 138bc75d-0d04-0410-961f-82ee72b054a4

16 files changed:
gcc/cp/ChangeLog
gcc/cp/constraint.cc
gcc/cp/cp-tree.h
gcc/cp/cvt.c
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/error.c
gcc/cp/friend.c
gcc/cp/init.c
gcc/cp/mangle.c
gcc/cp/method.c
gcc/cp/name-lookup.c
gcc/cp/pt.c
gcc/cp/semantics.c
gcc/cp/tree.c
gcc/cp/typeck.c

index ee25eface709272922f4b3a07277d3102b6749c1..c094ea0d63e1de36bb4e88d2a6b815559ad2c051 100644 (file)
@@ -1,5 +1,28 @@
 2017-05-16  Nathan Sidwell  <nathan@acm.org>
 
+       * cp-tree.h (OVL_FIRST, OVL_NAME): New.
+       (ovl_first): New.
+       * constexpr.c (function_concept_check): Use OVL_FIRST.
+       * cvt.c (build_expr_type_conversion): Likewise.
+       * decl.c (poplevel, grokdeclarator): Use OVL_NAME.
+       * decl2.c (mark_used): Use OVL_FIRST.
+       * error.c (dump_decl): Use OVL_FIRST, OVL_NAME.
+       (dump_expr, location_of): Use OVL_FIRST.
+       * friend.c (do_friend): Use OVL_NAME.
+       * init.c (build_offset_ref): Use OVL_FIRST.
+       * mangle.c (write_member_name): Likewise.
+       (write_expression): Use OVL_NAME.
+       * method.c (strip_inheriting_ctors): Use OVL_FIRST.
+       * name-lookup.c (pushdecl_class_level): Use OVL_NAME.
+       * pt.c (check_explicit_specialization): Use OVL_FIRST.
+       (check_template_shadow): Likewise.
+       (tsubst_template_args): Use OVL_NAME.
+       (tsubst_baselink): Use OVL_FIRST.
+       * semantics.c (perform_koenig_lookup): Use OVL_NAME.
+       * tree.c (get_first_fn): Use OVL_FIRST.
+       * typeck.c (finish_class_member_access_expr): Use OVL_NAME.
+       (cp_build_addr_expr_1): Use OVL_FIRST.
+
        * pt.c (tsubst_copy_and_build): Remove unnecessary COMPONENT_REF
        peeking.
        * semantics.c (finish_id_expression): Directly init local var.
index 3783553152ad09679a8ef68b974f50ffb77f2a9f..59b315159bed7cc37a3dd3dfb7a33c1a5528f184 100644 (file)
@@ -117,10 +117,9 @@ function_concept_check_p (tree t)
   gcc_assert (TREE_CODE (t) == CALL_EXPR);
   tree fn = CALL_EXPR_FN (t);
   if (fn != NULL_TREE
-      && TREE_CODE (fn) == TEMPLATE_ID_EXPR
-      && TREE_CODE (TREE_OPERAND (fn, 0)) == OVERLOAD)
+      && TREE_CODE (fn) == TEMPLATE_ID_EXPR)
     {
-      tree f1 = get_first_fn (fn);
+      tree f1 = OVL_FIRST (TREE_OPERAND (fn, 0));
       if (TREE_CODE (f1) == TEMPLATE_DECL
          && DECL_DECLARED_CONCEPT_P (DECL_TEMPLATE_RESULT (f1)))
         return true;
index 8244a768c91050b82fa424fe7ed1c6d042b13b84..8dee22f42f93ba11234d677a6623e8ccea13a2c4 100644 (file)
@@ -626,6 +626,11 @@ typedef struct ptrmem_cst * ptrmem_cst_t;
    and can be freed afterward.  */
 #define OVL_ARG_DEPENDENT(NODE) TREE_LANG_FLAG_0 (OVERLOAD_CHECK (NODE))
 
+/* The first decl of an overload.  */
+#define OVL_FIRST(NODE)        ovl_first (NODE)
+/* The name of the overload set.  */
+#define OVL_NAME(NODE) DECL_NAME (OVL_FIRST (NODE))
+
 struct GTY(()) tree_overload {
   struct tree_common common;
   tree function;
@@ -6668,6 +6673,13 @@ extern tree hash_tree_cons                       (tree, tree, tree);
 extern tree hash_tree_chain                    (tree, tree);
 extern tree build_qualified_name               (tree, tree, tree, bool);
 extern tree build_ref_qualified_type           (tree, cp_ref_qualifier);
+inline tree
+ovl_first (tree node)
+{
+  while (TREE_CODE (node) == OVERLOAD)
+    node = OVL_FUNCTION (node);
+  return node;
+}
 extern int is_overloaded_fn                    (tree);
 extern tree dependent_name                     (tree);
 extern tree get_fns                            (tree);
index 5f4b5e30a5fe2f0e893fbb9501d9165f3ceb6a65..a53c0b3751a25592fd3a346e114b238ed67a440c 100644 (file)
@@ -1722,7 +1722,7 @@ build_expr_type_conversion (int desires, tree expr, bool complain)
       int win = 0;
       tree candidate;
       tree cand = TREE_VALUE (conv);
-      cand = OVL_CURRENT (cand);
+      cand = OVL_FIRST (cand);
 
       if (winner && winner == cand)
        continue;
index 476fd8da2ef8c589e5e56ea02254b819f37c4ca4..7fe0be3584c195db967cfdee8f404ad370c4ba5c 100644 (file)
@@ -683,7 +683,7 @@ poplevel (int keep, int reverse, int functionbody)
   for (link = decls; link; link = TREE_CHAIN (link))
     {
       decl = TREE_CODE (link) == TREE_LIST ? TREE_VALUE (link) : link;
-      tree name = DECL_NAME (OVL_CURRENT (decl));
+      tree name = OVL_NAME (decl);
 
       if (leaving_for_scope && VAR_P (decl)
          /* It's hard to make this ARM compatibility hack play nicely with
@@ -10104,10 +10104,7 @@ grokdeclarator (const cp_declarator *declarator,
                      if (variable_template_p (dname))
                        dname = DECL_NAME (dname);
                      else
-                       {
-                         gcc_assert (is_overloaded_fn (dname));
-                         dname = DECL_NAME (get_first_fn (dname));
-                       }
+                       dname = OVL_NAME (dname);
                    }
                }
                /* Fall through.  */
index 46959ec77f778837c2ef29edd1f8b4c69ac8c207..4b99a8ebe8d8e01075d7d7efea3c422e62fd9c44 100644 (file)
@@ -5029,7 +5029,7 @@ mark_used (tree decl, tsubst_flags_t complain)
       decl = BASELINK_FUNCTIONS (decl);
       if (really_overloaded_fn (decl))
        return true;
-      decl = OVL_CURRENT (decl);
+      decl = OVL_FIRST (decl);
     }
 
   /* Set TREE_USED for the benefit of -Wunused.  */
index 0912d2d66b94e756a6723cf4f2ac363b897b633b..e8136d3eca10efd8f619a3540299334493684118 100644 (file)
@@ -1208,7 +1208,7 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags)
 
       /* If there's only one function, just treat it like an ordinary
         FUNCTION_DECL.  */
-      t = OVL_CURRENT (t);
+      t = OVL_FIRST (t);
       /* Fall through.  */
 
     case FUNCTION_DECL:
@@ -1235,10 +1235,8 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags)
        tree name = TREE_OPERAND (t, 0);
        tree args = TREE_OPERAND (t, 1);
 
-       if (is_overloaded_fn (name))
-         name = get_first_fn (name);
-       if (DECL_P (name))
-         name = DECL_NAME (name);
+       if (!identifier_p (name))
+         name = OVL_NAME (name);
        dump_decl (pp, name, flags);
        pp_cxx_begin_template_argument_list (pp);
        if (args == error_mark_node)
@@ -2498,7 +2496,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
              /* A::f */
              dump_expr (pp, t, flags | TFF_EXPR_IN_PARENS);
            else if (BASELINK_P (t))
-             dump_expr (pp, OVL_CURRENT (BASELINK_FUNCTIONS (t)),
+             dump_expr (pp, OVL_FIRST (BASELINK_FUNCTIONS (t)),
                         flags | TFF_EXPR_IN_PARENS);
            else
              dump_decl (pp, t, flags);
@@ -3004,7 +3002,7 @@ location_of (tree t)
        return input_location;
     }
   else if (TREE_CODE (t) == OVERLOAD)
-    t = OVL_FUNCTION (t);
+    t = OVL_FIRST (t);
 
   if (DECL_P (t))
     return DECL_SOURCE_LOCATION (t);
index 8708fe596a253862df83c82cdd458dae49352e56..834a1544a54267795f21a94c694c4de3b4a3dda9 100644 (file)
@@ -494,8 +494,7 @@ do_friend (tree ctype, tree declarator, tree decl,
   if (TREE_CODE (declarator) == TEMPLATE_ID_EXPR)
     {
       declarator = TREE_OPERAND (declarator, 0);
-      if (is_overloaded_fn (declarator))
-       declarator = DECL_NAME (get_first_fn (declarator));
+      declarator = OVL_NAME (declarator);
     }
 
   if (ctype)
index 00916d73a9103f3cb3c5d64047d383426dd0fd60..a905af8c85a9a204538eec0dc3a70f39894d2a2c 100644 (file)
@@ -2063,7 +2063,7 @@ build_offset_ref (tree type, tree member, bool address_p,
       if (TREE_CODE (t) != TEMPLATE_ID_EXPR && !really_overloaded_fn (t))
        {
          /* Get rid of a potential OVERLOAD around it.  */
-         t = OVL_CURRENT (t);
+         t = OVL_FIRST (t);
 
          /* Unique functions are handled easily.  */
 
index 9ee74a776ac6ee15d6a6c26a8475f13308080518..42290fee6750747bf46073aa03a7ef22f5e74362 100644 (file)
@@ -2833,8 +2833,7 @@ write_member_name (tree member)
   else if (TREE_CODE (member) == TEMPLATE_ID_EXPR)
     {
       tree name = TREE_OPERAND (member, 0);
-      if (TREE_CODE (name) == OVERLOAD)
-       name = OVL_FUNCTION (name);
+      name = OVL_FIRST (name);
       write_member_name (name);
       write_template_args (TREE_OPERAND (member, 1));
     }
@@ -3053,10 +3052,7 @@ write_expression (tree expr)
   else if (TREE_CODE (expr) == TEMPLATE_ID_EXPR)
     {
       tree fn = TREE_OPERAND (expr, 0);
-      if (is_overloaded_fn (fn))
-       fn = get_first_fn (fn);
-      if (DECL_P (fn))
-       fn = DECL_NAME (fn);
+      fn = OVL_NAME (fn);
       if (IDENTIFIER_OPNAME_P (fn))
        write_string ("on");
       write_unqualified_id (fn);
@@ -3257,7 +3253,7 @@ write_expression (tree expr)
            if ((TREE_CODE (fn) == FUNCTION_DECL
                 || TREE_CODE (fn) == OVERLOAD)
                && type_dependent_expression_p_push (expr))
-             fn = DECL_NAME (get_first_fn (fn));
+             fn = OVL_NAME (fn);
 
            write_expression (fn);
          }
index 6a2f18ce0fd211436115ca6ecd381d5b1cd45cff..a9bc4907eb716b6653fa40d7a82260e1fae97672 100644 (file)
@@ -502,10 +502,8 @@ strip_inheriting_ctors (tree dfn)
     return dfn;
   tree fn = dfn;
   while (tree inh = DECL_INHERITED_CTOR (fn))
-    {
-      inh = OVL_CURRENT (inh);
-      fn = inh;
-    }
+    fn = OVL_FIRST (inh);
+
   if (TREE_CODE (fn) == TEMPLATE_DECL
       && TREE_CODE (dfn) == FUNCTION_DECL)
     fn = DECL_TEMPLATE_RESULT (fn);
index 7b4d27f44d02d946606a431c2151d66b900856fc..1de8680faf558d4871e1dbbab12a16ba416e01d4 100644 (file)
@@ -3610,7 +3610,6 @@ set_inherited_value_binding_p (cxx_binding *binding, tree decl,
 bool
 pushdecl_class_level (tree x)
 {
-  tree name;
   bool is_valid = true;
   bool subtime;
 
@@ -3621,10 +3620,7 @@ pushdecl_class_level (tree x)
 
   subtime = timevar_cond_start (TV_NAME_LOOKUP);
   /* Get the name of X.  */
-  if (TREE_CODE (x) == OVERLOAD)
-    name = DECL_NAME (get_first_fn (x));
-  else
-    name = DECL_NAME (x);
+  tree name = OVL_NAME (x);
 
   if (name)
     {
index 8f120aa144603b8139f71bbfb5fc7a7573465e63..aa6af295c0fee546f04cf0e977896ac5ded8ec70 100644 (file)
@@ -2930,7 +2930,7 @@ check_explicit_specialization (tree declarator,
                     methods->iterate (idx, &ovl);
                     ++idx)
                  {
-                   if (!DECL_CONV_FN_P (OVL_CURRENT (ovl)))
+                   if (!DECL_CONV_FN_P (OVL_FIRST (ovl)))
                      /* There are no more conversion functions.  */
                      break;
 
@@ -3910,8 +3910,7 @@ check_template_shadow (tree decl)
     return true;
 
   /* Figure out what we're shadowing.  */
-  if (TREE_CODE (decl) == OVERLOAD)
-    decl = OVL_CURRENT (decl);
+  decl = OVL_FIRST (decl);
   olddecl = innermost_non_namespace_value (DECL_NAME (decl));
 
   /* If there's no previous binding for this name, we're not shadowing
@@ -14128,7 +14127,7 @@ tsubst_baselink (tree baselink, tree object_type,
          template_args = tsubst_template_args (template_args, args,
                                                complain, in_decl);
       }
-    name = DECL_NAME (get_first_fn (fns));
+    name = OVL_NAME (fns);
     if (IDENTIFIER_TYPENAME_P (name))
       name = mangle_conv_op_name_for_type (optype);
     baselink = lookup_fnfields (qualifying_scope, name, /*protect=*/1);
@@ -14150,7 +14149,7 @@ tsubst_baselink (tree baselink, tree object_type,
     if (BASELINK_P (baselink))
       fns = BASELINK_FUNCTIONS (baselink);
     if (!template_id_p && !really_overloaded_fn (fns)
-       && !mark_used (OVL_CURRENT (fns), complain) && !(complain & tf_error))
+       && !mark_used (OVL_FIRST (fns), complain) && !(complain & tf_error))
       return error_mark_node;
 
     /* Add back the template arguments, if present.  */
index 6c46823cec0ce6a3892a632b2d9fe13bdde7f612..d9e1ee39d618ee81b8d796bff1ad86d45565a5f2 100644 (file)
@@ -2231,15 +2231,10 @@ perform_koenig_lookup (cp_expr fn, vec<tree, va_gc> *args,
   /* Find the name of the overloaded function.  */
   if (identifier_p (fn))
     identifier = fn;
-  else if (is_overloaded_fn (fn))
-    {
-      functions = fn;
-      identifier = DECL_NAME (get_first_fn (functions));
-    }
-  else if (DECL_P (fn))
+  else
     {
       functions = fn;
-      identifier = DECL_NAME (fn);
+      identifier = OVL_NAME (functions);
     }
 
   /* A call to a namespace-scope function using an unqualified name.
index 2382f14b57133c669ec7af350691e8eb17b219e7..7b621736d6aa198b32152d7519debf62f382467d 100644 (file)
@@ -2169,7 +2169,7 @@ get_fns (tree from)
 tree
 get_first_fn (tree from)
 {
-  return OVL_CURRENT (get_fns (from));
+  return OVL_FIRST (get_fns (from));
 }
 
 /* Return a new OVL node, concatenating it with the old one.  */
index 6bc88a9d780ea11963d5ae510309e7b36241439d..6f15c9be07b7da1eb7523520dc7ce94986c663ed 100644 (file)
@@ -2764,10 +2764,8 @@ finish_class_member_access_expr (cp_expr object, tree name, bool template_p,
          template_args = TREE_OPERAND (name, 1);
          name = TREE_OPERAND (name, 0);
 
-         if (TREE_CODE (name) == OVERLOAD)
-           name = DECL_NAME (get_first_fn (name));
-         else if (DECL_P (name))
-           name = DECL_NAME (name);
+         if (!identifier_p (name))
+           name = OVL_NAME (name);
        }
 
       if (scope)
@@ -5746,7 +5744,7 @@ cp_build_addr_expr_1 (tree arg, bool strict_lvalue, tsubst_flags_t complain)
       /* Fall through.  */
 
     case OVERLOAD:
-      arg = OVL_CURRENT (arg);
+      arg = OVL_FIRST (arg);
       break;
 
     case OFFSET_REF: