c++: Create fewer SAVE_EXPR.
authorJason Merrill <jason@redhat.com>
Wed, 15 Jan 2020 03:55:59 +0000 (22:55 -0500)
committerJason Merrill <jason@redhat.com>
Mon, 18 May 2020 20:17:59 +0000 (16:17 -0400)
In a couple of places in build_over_call we were calling
cp_stabilize_reference but only using the result once, so it isn't needed.

gcc/cp/ChangeLog
2020-05-18  Jason Merrill  <jason@redhat.com>

* call.c (build_over_call): Remove unnecessary
cp_stabilize_reference.

gcc/cp/ChangeLog
gcc/cp/call.c

index e9cd3eb453bbc9ccbc24f63654ca637a5623fcba..1c4d0657c36a9f738acb4ded9b9c8c1f69da7b66 100644 (file)
@@ -1,3 +1,8 @@
+2020-05-18  Jason Merrill  <jason@redhat.com>
+
+       * call.c (build_over_call): Remove unnecessary
+       cp_stabilize_reference.
+
 2020-05-18  Marek Polacek  <polacek@redhat.com>
 
        * call.c (add_builtin_candidate): Don't create a builtin overload
index b96bc06a364b33ffba327c75fec59d6d449da88a..0b0eaa65ad86b6b3b6c50bc248a368e2cccd4be1 100644 (file)
@@ -9003,8 +9003,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
       else if ((trivial || TREE_CODE (arg) == TARGET_EXPR)
               && !unsafe)
        {
-         tree to = cp_stabilize_reference (cp_build_fold_indirect_ref (fa));
-
+         tree to = cp_build_fold_indirect_ref (fa);
          val = build2 (INIT_EXPR, DECL_CONTEXT (fn), to, arg);
          return val;
        }
@@ -9013,8 +9012,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
           && DECL_OVERLOADED_OPERATOR_IS (fn, NOP_EXPR)
           && trivial_fn_p (fn))
     {
-      tree to = cp_stabilize_reference
-       (cp_build_fold_indirect_ref (argarray[0]));
+      tree to = cp_build_fold_indirect_ref (argarray[0]);
       tree type = TREE_TYPE (to);
       tree as_base = CLASSTYPE_AS_BASE (type);
       tree arg = argarray[1];
@@ -9043,6 +9041,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
          tree array_type, alias_set;
 
          arg2 = TYPE_SIZE_UNIT (as_base);
+         to = cp_stabilize_reference (to);
          arg0 = cp_build_addr_expr (to, complain);
 
          array_type = build_array_type (unsigned_char_type_node,