* decl.c (move_signature_fn_p): Split out from move_fn_p.
* method.c (process_subob_fn): Use it.
* cp-tree.h: Declare it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@191146
138bc75d-0d04-0410-961f-
82ee72b054a4
2012-09-10 Jason Merrill <jason@redhat.com>
2012-09-10 Jason Merrill <jason@redhat.com>
+ PR c++/54506
+ * decl.c (move_signature_fn_p): Split out from move_fn_p.
+ * method.c (process_subob_fn): Use it.
+ * cp-tree.h: Declare it.
+
PR c++/54341
PR c++/54253
* semantics.c (sort_constexpr_mem_initializers): New.
PR c++/54341
PR c++/54253
* semantics.c (sort_constexpr_mem_initializers): New.
extern tree build_this_parm (tree, cp_cv_quals);
extern int copy_fn_p (const_tree);
extern bool move_fn_p (const_tree);
extern tree build_this_parm (tree, cp_cv_quals);
extern int copy_fn_p (const_tree);
extern bool move_fn_p (const_tree);
+extern bool move_signature_fn_p (const_tree);
extern tree get_scope_of_declarator (const cp_declarator *);
extern void grok_special_member_properties (tree);
extern int grok_ctor_properties (const_tree, const_tree);
extern tree get_scope_of_declarator (const cp_declarator *);
extern void grok_special_member_properties (tree);
extern int grok_ctor_properties (const_tree, const_tree);
bool
move_fn_p (const_tree d)
{
bool
move_fn_p (const_tree d)
{
- tree args;
- tree arg_type;
- bool result = false;
-
gcc_assert (DECL_FUNCTION_MEMBER_P (d));
if (cxx_dialect == cxx98)
gcc_assert (DECL_FUNCTION_MEMBER_P (d));
if (cxx_dialect == cxx98)
if (TREE_CODE (d) == TEMPLATE_DECL
|| (DECL_TEMPLATE_INFO (d)
&& DECL_MEMBER_TEMPLATE_P (DECL_TI_TEMPLATE (d))))
if (TREE_CODE (d) == TEMPLATE_DECL
|| (DECL_TEMPLATE_INFO (d)
&& DECL_MEMBER_TEMPLATE_P (DECL_TI_TEMPLATE (d))))
- /* Instantiations of template member functions are never copy
+ /* Instantiations of template member functions are never move
functions. Note that member functions of templated classes are
represented as template functions internally, and we must
functions. Note that member functions of templated classes are
represented as template functions internally, and we must
- accept those as copy functions. */
+ accept those as move functions. */
+ return move_signature_fn_p (d);
+}
+
+/* D is a constructor or overloaded `operator='.
+
+ Then, this function returns true when D has the same signature as a move
+ constructor or move assignment operator (because either it is such a
+ ctor/op= or it is a template specialization with the same signature),
+ false otherwise. */
+
+bool
+move_signature_fn_p (const_tree d)
+{
+ tree args;
+ tree arg_type;
+ bool result = false;
+
args = FUNCTION_FIRST_USER_PARMTYPE (d);
if (!args)
return 0;
args = FUNCTION_FIRST_USER_PARMTYPE (d);
if (!args)
return 0;
- /* Core 1402: A non-trivial copy op suppresses the implicit
+ /* Core 1402: A non-trivial non-move ctor suppresses the implicit
declaration of the move ctor/op=. */
declaration of the move ctor/op=. */
- if (no_implicit_p && move_p && !move_fn_p (fn) && !trivial_fn_p (fn))
+ if (no_implicit_p && move_p && !move_signature_fn_p (fn)
+ && !trivial_fn_p (fn))
*no_implicit_p = true;
if (constexpr_p && !DECL_DECLARED_CONSTEXPR_P (fn))
*no_implicit_p = true;
if (constexpr_p && !DECL_DECLARED_CONSTEXPR_P (fn))
2012-09-10 Jason Merrill <jason@redhat.com>
2012-09-10 Jason Merrill <jason@redhat.com>
+ PR c++/54506
+ * g++.dg/cpp0x/implicit14.C: New.
+
PR c++/54341
PR c++/54253
* g++.dg/cpp0x/constexpr-virtual2.C: New.
PR c++/54341
PR c++/54253
* g++.dg/cpp0x/constexpr-virtual2.C: New.
--- /dev/null
+// PR c++/54506
+// { dg-do compile { target c++11 } }
+
+template <class T>
+struct A
+{
+ A() {}
+
+ A(A const volatile &&) = delete;
+ A &operator =(A const volatile &&) = delete;
+
+ template <class U> A(A<U> &&) {}
+ template <class U> A &operator =(A<U> &&) { return *this; }
+};
+
+struct B
+{
+ A<int> a;
+ B() = default;
+};
+
+int main()
+{
+ B b = B();
+ b = B();
+}