+/* Returns true if we should avoid even doing overload resolution for copying
+ EXPR to initialize a TYPE. */
+
+bool
+early_elide_copy (tree type, tree expr)
+{
+ if (TREE_CODE (expr) != TARGET_EXPR)
+ return false;
+ /* List-initialization and direct-initialization don't involve a copy. */
+ if (TARGET_EXPR_LIST_INIT_P (expr)
+ || TARGET_EXPR_DIRECT_INIT_P (expr))
+ return true;
+ /* In C++17, "If the initializer expression is a prvalue and the
+ cv-unqualified version of the source type is the same class as the class
+ of the destination, the initializer expression is used to initialize the
+ destination object." */
+ return (cxx_dialect >= cxx1z
+ && (same_type_ignoring_top_level_qualifiers_p
+ (type, TREE_TYPE (expr))));
+}
+