summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/rv-trivial-bug.C
blob: 2765b5f3c30e57a4f8c8b37b6a8cac1c761e0aec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// { dg-options "-std=c++0x" }
// PR c++/33235
#include <cassert>

int move_construct = 0;
int move_assign = 0;

struct base2
{
    base2() {}
    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);		// { 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;			// { dg-error "lvalue" }
    assert(move_assign == 0);
    b = static_cast<base2&&>(b2);
    assert(move_assign == 1);
}

int main()
{
    test2();
    return 0;
}