* class.c (type_has_nontrivial_assignment): Remove.
* cp-tree.h: Remove declaration.
* init.c (vec_copy_assign_is_trivial): New.
(build_vec_init): Use it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224904
138bc75d-0d04-0410-961f-
82ee72b054a4
+2015-06-24 Jason Merrill <jason@redhat.com>
+
+ PR c++/66501
+ * class.c (type_has_nontrivial_assignment): Remove.
+ * cp-tree.h: Remove declaration.
+ * init.c (vec_copy_assign_is_trivial): New.
+ (build_vec_init): Use it.
+
2015-06-24 Edward Smith-Rowland <3dw4rd@verizon.net>
Implement N3928 - Extending static_assert
return false;
}
-/* Return true if TYPE has some non-trivial assignment operator. */
-
-bool
-type_has_nontrivial_assignment (tree type)
-{
- gcc_assert (TREE_CODE (type) != ARRAY_TYPE);
- if (CLASS_TYPE_P (type))
- for (tree fns
- = lookup_fnfields_slot_nolazy (type, ansi_assopname (NOP_EXPR));
- fns; fns = OVL_NEXT (fns))
- {
- tree fn = OVL_CURRENT (fns);
- if (!trivial_fn_p (fn))
- return true;
- }
- return false;
-}
-
/* TYPE is being used as a virtual base, and has a non-trivial move
assignment. Return true if this is due to there being a user-provided
move assignment in TYPE or one of its subobjects; if there isn't, then
extern bool user_provided_p (tree);
extern bool type_has_user_provided_constructor (tree);
extern bool type_has_non_user_provided_default_constructor (tree);
-extern bool type_has_nontrivial_assignment (tree);
extern bool vbase_has_user_provided_move_assign (tree);
extern tree default_init_uninitialized_part (tree);
extern bool trivial_default_constructor_is_constexpr (tree);
return decl;
}
+/* Subroutine of build_vec_init. Returns true if assigning to an array of
+ INNER_ELT_TYPE from INIT is trivial. */
+
+static bool
+vec_copy_assign_is_trivial (tree inner_elt_type, tree init)
+{
+ tree fromtype = inner_elt_type;
+ if (real_lvalue_p (init))
+ fromtype = cp_build_reference_type (fromtype, /*rval*/false);
+ return is_trivially_xible (MODIFY_EXPR, inner_elt_type, fromtype);
+}
+
/* `build_vec_init' returns tree structure that performs
initialization of a vector of aggregate types.
&& TREE_CODE (atype) == ARRAY_TYPE
&& TREE_CONSTANT (maxindex)
&& (from_array == 2
- ? !type_has_nontrivial_assignment (inner_elt_type)
+ ? vec_copy_assign_is_trivial (inner_elt_type, init)
: !TYPE_NEEDS_CONSTRUCTING (type))
&& ((TREE_CODE (init) == CONSTRUCTOR
/* Don't do this if the CONSTRUCTOR might contain something