Commit d758e847 by Jason Merrill Committed by Jason Merrill

Enable implicitly declared move constructor/operator= (N3053).

gcc/cp/
	* class.c (add_implicitly_declared_members): A class with no
	explicitly declared copy or move constructor gets both declared
	implicitly, and similarly for operator=.
	(check_bases): A type with no copy ctor does not inhibit
	a const copy ctor in a derived class.
	(check_field_decl): Likewise.
	(check_bases_and_members): A nonexistent copy ctor/op= is non-trivial.
	* tree.c (type_has_nontrivial_copy_init): Adjust semantics.
	(trivially_copyable_p): Likewise.
	* call.c (convert_like_real): Use type_has_nontrivial_copy_init.
	* class.c (finish_struct_bits): Likewise.
	* tree.c (build_target_expr_with_type): Likewise.
	* typeck2.c (store_init_value): Likewise.
libstdc++-v3/
	* include/bits/unordered_map.h: Explicitly default copy constructors.
	* include/bits/unordered_set.h: Likewise.

From-SVN: r161582
parent 54ca9930
2010-06-29 Jason Merrill <jason@redhat.com>
Enable implicitly declared move constructor/operator= (N3053).
* class.c (add_implicitly_declared_members): A class with no
explicitly declared copy or move constructor gets both declared
implicitly, and similarly for operator=.
(check_bases): A type with no copy ctor does not inhibit
a const copy ctor in a derived class. It does mean the derived
one is non-trivial.
(check_field_decl): Likewise.
(check_bases_and_members): A nonexistent copy ctor/op= is non-trivial.
* tree.c (type_has_nontrivial_copy_init): Adjust semantics.
(trivially_copyable_p): Likewise.
* call.c (convert_like_real): Use type_has_nontrivial_copy_init.
* class.c (finish_struct_bits): Likewise.
* tree.c (build_target_expr_with_type): Likewise.
* typeck2.c (store_init_value): Likewise.
Enable implicitly deleted functions (N2346)
* class.c (check_bases_and_members): Adjust lambda flags.
* method.c (implicitly_declare_fn): Set DECL_DELETED_FN if appropriate.
......
......@@ -5197,7 +5197,7 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum,
OK. */
if ((lvalue & clk_packed)
&& CLASS_TYPE_P (type)
&& !TYPE_HAS_TRIVIAL_COPY_CTOR (type))
&& type_has_nontrivial_copy_init (type))
{
if (complain & tf_error)
error ("cannot bind packed field %qE to %qT",
......@@ -5905,7 +5905,7 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
if (TREE_CODE (arg) == TARGET_EXPR)
return arg;
else if (trivial)
return build_target_expr_with_type (arg, DECL_CONTEXT (fn));
return force_target_expr (DECL_CONTEXT (fn), arg);
}
else if (TREE_CODE (arg) == TARGET_EXPR || trivial)
{
......
......@@ -1282,7 +1282,8 @@ check_bases (tree t,
assignment operators that take const references, then the
derived class cannot have such a member automatically
generated. */
if (! TYPE_HAS_CONST_COPY_CTOR (basetype))
if (TYPE_HAS_COPY_CTOR (basetype)
&& ! TYPE_HAS_CONST_COPY_CTOR (basetype))
*cant_have_const_ctor_p = 1;
if (TYPE_HAS_COPY_ASSIGN (basetype)
&& !TYPE_HAS_CONST_COPY_ASSIGN (basetype))
......@@ -1312,8 +1313,10 @@ check_bases (tree t,
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)
|= TYPE_HAS_NONTRIVIAL_DESTRUCTOR (basetype);
TYPE_HAS_COMPLEX_COPY_ASSIGN (t)
|= TYPE_HAS_COMPLEX_COPY_ASSIGN (basetype);
TYPE_HAS_COMPLEX_COPY_CTOR (t) |= TYPE_HAS_COMPLEX_COPY_CTOR (basetype);
|= (TYPE_HAS_COMPLEX_COPY_ASSIGN (basetype)
|| !TYPE_HAS_COPY_ASSIGN (basetype));
TYPE_HAS_COMPLEX_COPY_CTOR (t) |= (TYPE_HAS_COMPLEX_COPY_CTOR (basetype)
|| !TYPE_HAS_COPY_CTOR (basetype));
TYPE_HAS_COMPLEX_MOVE_ASSIGN (t)
|= TYPE_HAS_COMPLEX_MOVE_ASSIGN (basetype);
TYPE_HAS_COMPLEX_MOVE_CTOR (t) |= TYPE_HAS_COMPLEX_MOVE_CTOR (basetype);
......@@ -1545,7 +1548,8 @@ finish_struct_bits (tree t)
mode to be BLKmode, and force its TREE_ADDRESSABLE bit to be
nonzero. This will cause it to be passed by invisible reference
and prevent it from being returned in a register. */
if (! TYPE_HAS_TRIVIAL_COPY_CTOR (t) || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t))
if (type_has_nontrivial_copy_init (t)
|| TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t))
{
tree variants;
DECL_MODE (TYPE_MAIN_DECL (t)) = BLKmode;
......@@ -2647,27 +2651,28 @@ add_implicitly_declared_members (tree t,
If a class definition does not explicitly declare a copy
constructor, one is declared implicitly. */
if (! TYPE_HAS_COPY_CTOR (t) && ! TYPE_FOR_JAVA (t))
if (! TYPE_HAS_COPY_CTOR (t) && ! TYPE_FOR_JAVA (t)
&& !type_has_move_constructor (t))
{
TYPE_HAS_COPY_CTOR (t) = 1;
TYPE_HAS_CONST_COPY_CTOR (t) = !cant_have_const_cctor;
CLASSTYPE_LAZY_COPY_CTOR (t) = 1;
if (cxx_dialect >= cxx0x)
CLASSTYPE_LAZY_MOVE_CTOR (t) = 1;
}
/* Currently only lambdas get a lazy move ctor, but N3053 adds them for
other classes. */
if (LAMBDA_TYPE_P (t))
CLASSTYPE_LAZY_MOVE_CTOR (t) = 1;
/* If there is no assignment operator, one will be created if and
when it is needed. For now, just record whether or not the type
of the parameter to the assignment operator will be a const or
non-const reference. */
if (!TYPE_HAS_COPY_ASSIGN (t) && !TYPE_FOR_JAVA (t))
if (!TYPE_HAS_COPY_ASSIGN (t) && !TYPE_FOR_JAVA (t)
&& !type_has_move_assign (t))
{
TYPE_HAS_COPY_ASSIGN (t) = 1;
TYPE_HAS_CONST_COPY_ASSIGN (t) = !cant_have_const_assignment;
CLASSTYPE_LAZY_COPY_ASSIGN (t) = 1;
if (cxx_dialect >= cxx0x)
CLASSTYPE_LAZY_MOVE_ASSIGN (t) = 1;
}
/* We can't be lazy about declaring functions that might override
......@@ -2863,18 +2868,23 @@ check_field_decl (tree field,
TYPE_NEEDS_CONSTRUCTING (t) |= TYPE_NEEDS_CONSTRUCTING (type);
TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)
|= TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type);
TYPE_HAS_COMPLEX_COPY_ASSIGN (t) |= TYPE_HAS_COMPLEX_COPY_ASSIGN (type);
TYPE_HAS_COMPLEX_COPY_CTOR (t) |= TYPE_HAS_COMPLEX_COPY_CTOR (type);
TYPE_HAS_COMPLEX_COPY_ASSIGN (t)
|= (TYPE_HAS_COMPLEX_COPY_ASSIGN (type)
|| !TYPE_HAS_COPY_ASSIGN (type));
TYPE_HAS_COMPLEX_COPY_CTOR (t) |= (TYPE_HAS_COMPLEX_COPY_CTOR (type)
|| !TYPE_HAS_COPY_CTOR (type));
TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) |= TYPE_HAS_COMPLEX_MOVE_ASSIGN (type);
TYPE_HAS_COMPLEX_MOVE_CTOR (t) |= TYPE_HAS_COMPLEX_MOVE_CTOR (type);
TYPE_HAS_COMPLEX_DFLT (t) |= (!TYPE_HAS_DEFAULT_CONSTRUCTOR (type)
|| TYPE_HAS_COMPLEX_DFLT (type));
}
if (!TYPE_HAS_CONST_COPY_CTOR (type))
if (TYPE_HAS_COPY_CTOR (type)
&& !TYPE_HAS_CONST_COPY_CTOR (type))
*cant_have_const_ctor = 1;
if (!TYPE_HAS_CONST_COPY_ASSIGN (type))
if (TYPE_HAS_COPY_ASSIGN (type)
&& !TYPE_HAS_CONST_COPY_ASSIGN (type))
*no_const_asn_ref = 1;
}
if (DECL_INITIAL (field) != NULL_TREE)
......
......@@ -479,7 +479,7 @@ build_target_expr_with_type (tree init, tree type)
if (TREE_CODE (init) == TARGET_EXPR)
return init;
else if (CLASS_TYPE_P (type) && !TYPE_HAS_TRIVIAL_COPY_CTOR (type)
else if (CLASS_TYPE_P (type) && type_has_nontrivial_copy_init (type)
&& !VOID_TYPE_P (TREE_TYPE (init))
&& TREE_CODE (init) != COND_EXPR
&& TREE_CODE (init) != CONSTRUCTOR
......@@ -497,7 +497,8 @@ build_target_expr_with_type (tree init, tree type)
/* Like the above function, but without the checking. This function should
only be used by code which is deliberately trying to subvert the type
system, such as call_builtin_trap. */
system, such as call_builtin_trap. Or build_over_call, to avoid
infinite recursion. */
tree
force_target_expr (tree type, tree init)
......@@ -2368,7 +2369,9 @@ type_has_nontrivial_default_init (const_tree t)
return 0;
}
/* Returns true iff copying an object of type T is non-trivial. */
/* Returns true iff copying an object of type T (including via move
constructor) is non-trivial. That is, T has no non-trivial copy
constructors and no non-trivial move constructors. */
bool
type_has_nontrivial_copy_init (const_tree t)
......@@ -2376,7 +2379,12 @@ type_has_nontrivial_copy_init (const_tree t)
t = strip_array_types (CONST_CAST_TREE (t));
if (CLASS_TYPE_P (t))
return TYPE_HAS_COMPLEX_COPY_CTOR (t);
{
gcc_assert (COMPLETE_TYPE_P (t));
return ((TYPE_HAS_COPY_CTOR (t)
&& TYPE_HAS_COMPLEX_COPY_CTOR (t))
|| TYPE_HAS_COMPLEX_MOVE_CTOR (t));
}
else
return 0;
}
......@@ -2390,8 +2398,12 @@ trivially_copyable_p (const_tree t)
t = strip_array_types (CONST_CAST_TREE (t));
if (CLASS_TYPE_P (t))
return (TYPE_HAS_TRIVIAL_COPY_CTOR (t)
&& TYPE_HAS_TRIVIAL_COPY_ASSIGN (t)
return ((!TYPE_HAS_COPY_CTOR (t)
|| !TYPE_HAS_COMPLEX_COPY_CTOR (t))
&& !TYPE_HAS_COMPLEX_MOVE_CTOR (t)
&& (!TYPE_HAS_COPY_ASSIGN (t)
|| !TYPE_HAS_COMPLEX_COPY_ASSIGN (t))
&& !TYPE_HAS_COMPLEX_MOVE_ASSIGN (t)
&& TYPE_HAS_TRIVIAL_DESTRUCTOR (t));
else
return scalarish_type_p (t);
......
......@@ -714,7 +714,7 @@ store_init_value (tree decl, tree init, int flags)
if (MAYBE_CLASS_TYPE_P (type))
{
gcc_assert (TYPE_HAS_TRIVIAL_COPY_CTOR (type)
gcc_assert (!type_has_nontrivial_copy_init (type)
|| TREE_CODE (init) == CONSTRUCTOR);
if (TREE_CODE (init) == TREE_LIST)
......
2010-06-29 Jason Merrill <jason@redhat.com>
Enable implicitly declared move constructor/operator= (N3053).
* g++.dg/cpp0x/implicit3.C: New.
* g++.dg/cpp0x/implicit4.C: New.
* g++.dg/cpp0x/implicit5.C: New.
* g++.dg/cpp0x/implicit-copy.C: Adjust.
* g++.dg/cpp0x/not_special.C: Adjust.
* g++.dg/cpp0x/rv-trivial-bug.C: Adjust.
* g++.dg/cpp0x/rv1n.C: Adjust.
* g++.dg/cpp0x/rv1p.C: Adjust.
* g++.dg/cpp0x/rv2n.C: Adjust.
* g++.dg/cpp0x/rv2p.C: Adjust.
* g++.dg/cpp0x/rv3n.C: Adjust.
* g++.dg/cpp0x/rv3p.C: Adjust.
* g++.dg/cpp0x/rv4n.C: Adjust.
* g++.dg/cpp0x/rv4p.C: Adjust.
* g++.dg/cpp0x/rv5n.C: Adjust.
* g++.dg/cpp0x/rv5p.C: Adjust.
* g++.dg/cpp0x/rv6n.C: Adjust.
* g++.dg/cpp0x/rv6p.C: Adjust.
* g++.dg/cpp0x/rv7n.C: Adjust.
* g++.dg/cpp0x/rv7p.C: Adjust.
* g++.dg/cpp0x/rv8p.C: Adjust.
* g++.dg/gomp/pr26690-1.C: Adjust.
* g++.dg/other/error20.C: Adjust.
* g++.dg/other/error31.C: Adjust.
* g++.dg/parse/error19.C: Adjust.
* g++.dg/template/qualttp5.C: Adjust.
* g++.old-deja/g++.law/ctors5.C: Adjust.
Enable implicitly deleted functions (N2346)
* g++.dg/cpp0x/defaulted17.C: New.
* g++.dg/cpp0x/implicit1.C: New.
......
......@@ -3,13 +3,13 @@ struct S
{
S();
private:
S(S const &&);
S & operator=(S const &&);
S(S const &&); // { dg-error "" }
S & operator=(S const &&); // { dg-error "" }
};
void f()
{
S a;
S b(a);
a = b;
S b(a); // { dg-error "" }
a = b; // { dg-error "" }
}
// Basic runtime test for implicit move constructor
// { dg-do run }
// { dg-options -std=c++0x }
int m;
struct A
{
A() = default;
A(A&&) { ++m; }
A& operator=(A&&) { ++m; return *this; }
};
struct B
{
B() = default;
B(const B&);
B(B&&) { ++m; }
B& operator=(const B&);
B& operator=(B&&) { ++m; return *this; }
};
struct C
{
C() = default;
C(C&);
C(C&&) { ++m; }
C& operator=(C&);
C& operator=(C&&) { ++m; return *this; }
};
struct D: public A, public B
{
C c;
int i;
};
struct E: public A, public B
{
C c;
int i;
E() = default;
E(E&&) = default;
E& operator=(E&&) = default;
};
int main()
{
D d1;
D d2 (static_cast<D&&>(d1));
d1 = static_cast<D&&>(d2);
E e1;
E e2 (static_cast<E&&>(e1));
e1 = static_cast<E&&>(e2);
return m != 12;
}
// Test that a base with only a move constructor causes the implicit copy
// constructor to be deleted.
// { dg-options "-std=c++0x" }
struct A
{
A(); // { dg-message "A::A" }
A(A&&); // { dg-message "A::A" }
};
struct B: A // { dg-error "implicit|no match" }
{
};
int main()
{
B b1;
B b2(b1); // { dg-error "deleted function .B::B.const" }
B b3(static_cast<B&&>(b1));
}
// Test that the default B copy constructor calls the A member template
// constructor.
// { dg-options -std=c++0x }
struct A
{
A() = default;
A(A&&) = default;
template <class T>
A(const T& t) { t.i; } // { dg-error "no member" }
};
struct B: A { };
int main()
{
B b;
B b2(b);
}
// I, Howard Hinnant, hereby place this code in the public domain.
// Test that move constructor and move assignement are not special.
// That is, their presence should not inhibit compiler generated
// copy ctor or assignment. Rather they should overload with the
// compiler generated special members.
// Test that move constructor and move assignement are special.
// That is, their presence should inhibit compiler generated
// copy ctor or assignment.
// { dg-do run }
// { dg-options "-std=c++0x" }
#include <assert.h>
......@@ -30,8 +28,8 @@ struct derived
: base
{
derived() {}
derived(derived&&) {}
derived& operator=(derived&&) {return *this;}
derived(derived&&) {} // { dg-error "argument 1" }
derived& operator=(derived&&) {return *this;} // { dg-error "argument 1" }
};
int test1()
......@@ -39,11 +37,11 @@ int test1()
derived d;
derived d2(static_cast<derived&&>(d)); // should not call base::(const base&)
assert(copy == 0);
derived d3(d); // should call base::(const base&)
derived d3(d); // { dg-error "lvalue" }
assert(copy == 1);
d2 = static_cast<derived&&>(d); // should not call base::operator=
assert(assign == 0);
d3 = d; // should call base::operator=
d3 = d; // { dg-error "lvalue" }
assert(assign == 1);
return 0;
}
......
// { dg-do "run" }
// { dg-options "-std=c++0x" }
// PR c++/33235
#include <cassert>
......@@ -9,19 +8,19 @@ int move_assign = 0;
struct base2
{
base2() {}
base2(base2&&) {++move_construct;}
base2& operator=(base2&&) {++move_assign; return *this;}
base2(base2&&) {++move_construct;} // { dg-error "argument 1" }
base2& operator=(base2&&) {++move_assign; return *this;} // { dg-error "argument 1" }
};
int test2()
{
base2 b;
base2 b2(b);
base2 b2(b); // { dg-error "lvalue" }
assert(move_construct == 0);
base2 b3(static_cast<base2&&>(b));
base2 b4 = static_cast<base2&&>(b);
assert(move_construct == 2);
b = b2;
b = b2; // { dg-error "lvalue" }
assert(move_assign == 0);
b = static_cast<base2&&>(b2);
assert(move_assign == 1);
......
......@@ -20,7 +20,7 @@ struct eight {char x[8];};
struct A
{
A();
A(const volatile A&&);
A(const volatile A&&); // { dg-error "argument 1" }
};
A source();
......@@ -35,9 +35,9 @@ one sink_1_1( A&); // { dg-error "" }
int test1_1()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "cannot bind" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "cannot bind" }
sink_1_1(ca); // { dg-error "invalid initialization" }
sink_1_1(va); // { dg-error "invalid initialization" }
sink_1_1(cva); // { dg-error "invalid initialization" }
......@@ -53,9 +53,9 @@ two sink_1_2(const A&); // { dg-error "" }
int test1_2()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_1_2(va); // { dg-error "invalid initialization" }
sink_1_2(cva); // { dg-error "invalid initialization" }
sink_1_2(v_source()); // { dg-error "invalid initialization" }
......@@ -68,9 +68,9 @@ three sink_1_3(volatile A&); // { dg-error "" }
int test1_3()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_1_3(ca); // { dg-error "invalid initialization" }
sink_1_3(cva); // { dg-error "invalid initialization" }
sink_1_3(source()); // { dg-error "invalid initialization" }
......@@ -85,9 +85,9 @@ four sink_1_4(const volatile A&); // { dg-error "" }
int test1_4()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_1_4(source()); // { dg-error "invalid initialization" }
sink_1_4(c_source()); // { dg-error "invalid initialization" }
sink_1_4(v_source()); // { dg-error "invalid initialization" }
......@@ -100,9 +100,9 @@ five sink_1_5( A&&); // { dg-error "" }
int test1_5()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_1_5(a); // { dg-error "lvalue" }
sink_1_5(ca); // { dg-error "invalid initialization" }
sink_1_5(va); // { dg-error "invalid initialization" }
......@@ -118,9 +118,9 @@ six sink_1_6(const A&&); // { dg-error "" }
int test1_6()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_1_6(a); // { dg-error "lvalue" }
sink_1_6(ca); // { dg-error "lvalue" }
sink_1_6(va); // { dg-error "invalid initialization" }
......@@ -135,9 +135,9 @@ seven sink_1_7(volatile A&&); // { dg-error "" }
int test1_7()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_1_7(a); // { dg-error "lvalue" }
sink_1_7(ca); // { dg-error "invalid initialization" }
sink_1_7(va); // { dg-error "lvalue" }
......@@ -152,9 +152,9 @@ eight sink_1_8(const volatile A&&); // { dg-error "" }
int test1_8()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_1_8(a); // { dg-error "lvalue" }
sink_1_8(ca); // { dg-error "lvalue" }
sink_1_8(va); // { dg-error "lvalue" }
......
......@@ -35,9 +35,9 @@ one sink_1_1( A&);
int test1_1()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_1_1(a)) == 1> t1;
return 0;
}
......@@ -47,9 +47,9 @@ two sink_1_2(const A&);
int test1_2()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_1_2(a)) == 2> t1;
sa<sizeof(sink_1_2(ca)) == 2> t2;
sa<sizeof(sink_1_2(source())) == 2> t5;
......@@ -62,9 +62,9 @@ three sink_1_3(volatile A&);
int test1_3()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_1_3(a)) == 3> t1;
sa<sizeof(sink_1_3(va)) == 3> t3;
return 0;
......@@ -75,9 +75,9 @@ four sink_1_4(const volatile A&);
int test1_4()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_1_4(a)) == 4> t1;
sa<sizeof(sink_1_4(ca)) == 4> t2;
sa<sizeof(sink_1_4(va)) == 4> t3;
......@@ -90,9 +90,9 @@ five sink_1_5( A&&);
int test1_5()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_1_5(source())) == 5> t5;
return 0;
}
......@@ -102,9 +102,9 @@ six sink_1_6(const A&&);
int test1_6()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_1_6(source())) == 6> t5;
sa<sizeof(sink_1_6(c_source())) == 6> t6;
return 0;
......@@ -115,9 +115,9 @@ seven sink_1_7(volatile A&&);
int test1_7()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_1_7(source())) == 7> t5;
sa<sizeof(sink_1_7(v_source())) == 7> t7;
return 0;
......@@ -128,9 +128,9 @@ eight sink_1_8(const volatile A&&);
int test1_8()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_1_8(source())) == 8> t5;
sa<sizeof(sink_1_8(c_source())) == 8> t6;
sa<sizeof(sink_1_8(v_source())) == 8> t7;
......
......@@ -20,7 +20,7 @@ struct eight {char x[8];};
struct A
{
A();
A(const volatile A&&);
A(const volatile A&&); // { dg-error "argument 1" }
};
A source();
......@@ -40,9 +40,9 @@ six sink_6_123456(const A&&); // { dg-message "note" }
int test6_123456()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_123456(v_source()); // { dg-error "no match" }
sink_6_123456(cv_source()); // { dg-error "no match" }
return 0;
......@@ -58,9 +58,9 @@ seven sink_6_123457(volatile A&&); // { dg-message "note" }
int test6_123457()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_123457(cv_source()); // { dg-error "no match" }
return 0;
}
......@@ -75,9 +75,9 @@ eight sink_6_235678(const volatile A&&); // { dg-message "" }
int test6_235678()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_235678(a); // { dg-error "ambiguous" }
sink_6_235678(cva); // { dg-error "lvalue" }
return 0;
......@@ -93,9 +93,9 @@ eight sink_6_234678(const volatile A&&); // { dg-message "note" }
int test6_234678()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_234678(a); // { dg-error "ambiguous" }
sink_6_234678(source()); // { dg-error "ambiguous" }
return 0;
......@@ -111,9 +111,9 @@ eight sink_6_234578(const volatile A&&); // { dg-message "note" }
int test6_234578()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_234578(a); // { dg-error "ambiguous" }
return 0;
}
......@@ -128,9 +128,9 @@ eight sink_6_234568(const volatile A&&); // { dg-message "note" }
int test6_234568()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_234568(a); // { dg-error "ambiguous" }
return 0;
}
......@@ -145,9 +145,9 @@ seven sink_6_234567(volatile A&&); // { dg-message "note" }
int test6_234567()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_234567(a); // { dg-error "ambiguous" }
sink_6_234567(cv_source()); // { dg-error "no match" }
return 0;
......@@ -163,9 +163,9 @@ eight sink_6_134678(const volatile A&&); // { dg-message "note" }
int test6_134678()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_134678(source()); // { dg-error "ambiguous" }
return 0;
}
......@@ -180,9 +180,9 @@ eight sink_6_124678(const volatile A&&); // { dg-message "note" }
int test6_124678()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_124678(source()); // { dg-error "ambiguous" }
return 0;
}
......@@ -197,9 +197,9 @@ eight sink_6_123678(const volatile A&&); // { dg-message "" }
int test6_123678()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_123678(cva); // { dg-error "lvalue" }
sink_6_123678(source()); // { dg-error "ambiguous" }
return 0;
......@@ -215,9 +215,9 @@ seven sink_6_123567(volatile A&&); // { dg-message "note" }
int test6_123567()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_123567(cva); // { dg-error "no match" }
sink_6_123567(cv_source()); // { dg-error "no match" }
return 0;
......@@ -233,9 +233,9 @@ eight sink_6_123568(const volatile A&&); // { dg-message "" }
int test6_123568()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_123568(cva); // { dg-error "lvalue" }
return 0;
}
......@@ -250,9 +250,9 @@ eight sink_6_123578(const volatile A&&); // { dg-message "" }
int test6_123578()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_123578(cva); // { dg-error "lvalue" }
return 0;
}
......@@ -267,9 +267,9 @@ seven sink_6_123467(volatile A&&); // { dg-message "note" }
int test6_123467()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_123467(source()); // { dg-error "ambiguous" }
sink_6_123467(cv_source()); // { dg-error "no match" }
return 0;
......@@ -285,9 +285,9 @@ seven sink_6_124567(volatile A&&); // { dg-message "note" }
int test6_124567()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_124567(cv_source()); // { dg-error "no match" }
return 0;
}
......@@ -302,9 +302,9 @@ eight sink_6_125678(const volatile A&&); // { dg-message "" }
int test6_125678()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_125678(va); // { dg-error "lvalue" }
sink_6_125678(cva); // { dg-error "lvalue" }
return 0;
......@@ -320,9 +320,9 @@ seven sink_6_134567(volatile A&&); // { dg-message "note" }
int test6_134567()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_134567(cv_source()); // { dg-error "no match" }
return 0;
}
......@@ -337,9 +337,9 @@ eight sink_6_135678(const volatile A&&); // { dg-message "" }
int test6_135678()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_6_135678(ca); // { dg-error "lvalue" }
sink_6_135678(cva); // { dg-error "lvalue" }
return 0;
......
......@@ -20,7 +20,7 @@ struct eight {char x[8];};
struct A
{
A();
A(const volatile A&&);
A(const volatile A&&); // { dg-error "argument 1" }
};
A source();
......@@ -41,9 +41,9 @@ seven sink_7_1234567(volatile A&&); // { dg-message "note" }
int test7_1234567()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_7_1234567(cv_source()); // { dg-error "no match" }
return 0;
}
......@@ -59,9 +59,9 @@ eight sink_7_1235678(const volatile A&&); // { dg-message "" }
int test7_1235678()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_7_1235678(cva); // { dg-error "lvalue" }
return 0;
}
......@@ -77,9 +77,9 @@ eight sink_7_2345678(const volatile A&&); // { dg-message "note" }
int test7_2345678()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_7_2345678(a); // { dg-error "ambiguous" }
return 0;
}
......@@ -95,9 +95,9 @@ eight sink_7_1234678(const volatile A&&); // { dg-message "note" }
int test7_1234678()
{
A a;
const A ca = a;
const A ca = a; // { dg-error "lvalue" }
volatile A va;
const volatile A cva = a;
const volatile A cva = a; // { dg-error "lvalue" }
sink_7_1234678(source()); // { dg-error "ambiguous" }
return 0;
}
......
......@@ -41,9 +41,9 @@ seven sink_7_1234567(volatile A&&);
int test7_1234567()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_7_1234567(a)) == 1> t1;
sa<sizeof(sink_7_1234567(ca)) == 2> t2;
sa<sizeof(sink_7_1234567(va)) == 3> t3;
......@@ -65,9 +65,9 @@ eight sink_7_1234568(const volatile A&&);
int test7_1234568()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_7_1234568(a)) == 1> t1;
sa<sizeof(sink_7_1234568(ca)) == 2> t2;
sa<sizeof(sink_7_1234568(va)) == 3> t3;
......@@ -90,9 +90,9 @@ eight sink_7_1234578(const volatile A&&);
int test7_1234578()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_7_1234578(a)) == 1> t1;
sa<sizeof(sink_7_1234578(ca)) == 2> t2;
sa<sizeof(sink_7_1234578(va)) == 3> t3;
......@@ -115,9 +115,9 @@ eight sink_7_1234678(const volatile A&&);
int test7_1234678()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_7_1234678(a)) == 1> t1;
sa<sizeof(sink_7_1234678(ca)) == 2> t2;
sa<sizeof(sink_7_1234678(va)) == 3> t3;
......@@ -139,9 +139,9 @@ eight sink_7_1235678(const volatile A&&);
int test7_1235678()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_7_1235678(a)) == 1> t1;
sa<sizeof(sink_7_1235678(ca)) == 2> t2;
sa<sizeof(sink_7_1235678(va)) == 3> t3;
......@@ -163,9 +163,9 @@ eight sink_7_1245678(const volatile A&&);
int test7_1245678()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_7_1245678(a)) == 1> t1;
sa<sizeof(sink_7_1245678(ca)) == 2> t2;
sa<sizeof(sink_7_1245678(va)) == 4> t3;
......@@ -188,9 +188,9 @@ eight sink_7_1345678(const volatile A&&);
int test7_1345678()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_7_1345678(a)) == 1> t1;
sa<sizeof(sink_7_1345678(ca)) == 4> t2;
sa<sizeof(sink_7_1345678(va)) == 3> t3;
......@@ -213,9 +213,9 @@ eight sink_7_2345678(const volatile A&&);
int test7_2345678()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_7_2345678(ca)) == 2> t2;
sa<sizeof(sink_7_2345678(va)) == 3> t3;
sa<sizeof(sink_7_2345678(cva)) == 4> t4;
......
......@@ -42,9 +42,9 @@ eight sink_8_12345678(const volatile A&&);
int test8_12345678()
{
A a;
const A ca = a;
const A ca;
volatile A va;
const volatile A cva = a;
const volatile A cva;
sa<sizeof(sink_8_12345678(a)) == 1> t1;
sa<sizeof(sink_8_12345678(ca)) == 2> t2;
sa<sizeof(sink_8_12345678(va)) == 3> t3;
......
// PR c++/26690
// { dg-do compile }
struct A // { dg-message "A::A\\(const A&\\)" }
struct A // { dg-message "A::A" }
{
A (int); // { dg-message "candidates" }
};
......
// PR c++/34275
// { dg-do compile }
struct A // { dg-message "candidate is" }
struct A // { dg-message "operator=" }
{
virtual A foo ();
};
......
......@@ -3,7 +3,7 @@
// { dg-options "" }
// { dg-bogus "not supported by" "" { target *-*-* } 0 }
struct A {}; // { dg-message "note: candidate is" }
struct A {}; // { dg-message "operator=" }
void
foo ()
......
// { dg-options "-fshow-column -fmessage-length=0 -ansi -pedantic-errors -Wno-long-long " }
// PR C++/17867
struct A // { dg-message "8:candidate is:" }
struct A // { dg-message "8:operator=" }
{
A(int);
};
......
......@@ -4,7 +4,7 @@
template <class U> struct A
{
template <class T> class B {}; // { dg-message "candidate is" }
template <class T> class B {}; // { dg-message "operator=" }
};
template <template <class> class TT> void f()
......
......@@ -5,7 +5,7 @@
// Subject: bug in handling static const object of the enclosing class
// Date: Tue, 1 Sep 92 10:38:44 EDT
class X // { dg-message "7:X::X\\(const X&\\)" } implicit constructor
class X // { dg-message "7:X::X" } implicit constructor
{
private:
int x;
......
2010-06-29 Jason Merrill <jason@redhat.com>
Enable implicitly declared move constructor/operator= (N3053).
* include/bits/unordered_map.h: Explicitly default copy constructors.
* include/bits/unordered_set.h: Likewise.
* 19_diagnostics/error_category/cons/copy_neg.cc: Adjust expected
errors, use dg-prune-output.
* 20_util/function/cmp/cmp_neg.cc: Likewise.
......
......@@ -82,6 +82,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
__eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
{ }
__unordered_map(const __unordered_map& __x) = default;
__unordered_map(__unordered_map&& __x)
: _Base(std::forward<_Base>(__x)) { }
};
......@@ -137,6 +139,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
__eql, std::_Select1st<std::pair<const _Key, _Tp> >(), __a)
{ }
__unordered_multimap(const __unordered_multimap& __x) = default;
__unordered_multimap(__unordered_multimap&& __x)
: _Base(std::forward<_Base>(__x)) { }
};
......@@ -246,6 +250,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
: _Base(__f, __l, __n, __hf, __eql, __a)
{ }
unordered_map(const unordered_map& __x) = default;
unordered_map(unordered_map&& __x)
: _Base(std::forward<_Base>(__x)) { }
......@@ -258,6 +264,9 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
{ }
unordered_map&
operator=(const unordered_map& __x) = default;
unordered_map&
operator=(unordered_map&& __x)
{
// NB: DR 1204.
......@@ -328,6 +337,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
: _Base(__f, __l, __n, __hf, __eql, __a)
{ }
unordered_multimap(const unordered_multimap& __x) = default;
unordered_multimap(unordered_multimap&& __x)
: _Base(std::forward<_Base>(__x)) { }
......@@ -340,6 +351,9 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
{ }
unordered_multimap&
operator=(const unordered_multimap& __x) = default;
unordered_multimap&
operator=(unordered_multimap&& __x)
{
// NB: DR 1204.
......
......@@ -82,6 +82,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
std::_Identity<_Value>(), __a)
{ }
__unordered_set(const __unordered_set& __x) = default;
__unordered_set(__unordered_set&& __x)
: _Base(std::forward<_Base>(__x)) { }
};
......@@ -135,6 +137,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
std::_Identity<_Value>(), __a)
{ }
__unordered_multiset(const __unordered_multiset& __x) = default;
__unordered_multiset(__unordered_multiset&& __x)
: _Base(std::forward<_Base>(__x)) { }
};
......@@ -239,6 +243,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
: _Base(__f, __l, __n, __hf, __eql, __a)
{ }
unordered_set(const unordered_set& __x) = default;
unordered_set(unordered_set&& __x)
: _Base(std::forward<_Base>(__x)) { }
......@@ -251,6 +257,9 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
{ }
unordered_set&
operator=(const unordered_set& __x) = default;
unordered_set&
operator=(unordered_set&& __x)
{
// NB: DR 1204.
......@@ -318,6 +327,8 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
: _Base(__f, __l, __n, __hf, __eql, __a)
{ }
unordered_multiset(const unordered_multiset& __x) = default;
unordered_multiset(unordered_multiset&& __x)
: _Base(std::forward<_Base>(__x)) { }
......@@ -330,6 +341,9 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
{ }
unordered_multiset&
operator=(const unordered_multiset& __x) = default;
unordered_multiset&
operator=(unordered_multiset&& __x)
{
// NB: DR 1204.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment