OSDN Git Service

PR c++/36628
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / cpp0x / elision_neg.C
1 // I, Howard Hinnant, hereby place this code in the public domain.
2
3 // Test: Implicit cast to rvalue when eliding copy
4
5 // { dg-do compile }
6 // { dg-options "-std=c++0x" }
7
8 template <bool> struct sa;
9 template <> struct sa<true> {};
10
11 struct one   {char x[1];};
12 struct two   {char x[2];};
13
14 class move_only
15 {
16     move_only(const move_only&); // { dg-error "is private" }
17     move_only& operator=(const move_only&);
18 public:
19     move_only() {}
20     move_only(move_only&&) {}
21     move_only& operator=(move_only&&) {return *this;}
22 };
23
24 move_only
25 test1()
26 {
27     static move_only x;
28     return x;  //  { dg-error "within this context" }
29 }
30
31 move_only
32 test2(move_only&& x)
33 {
34     return x;  //  { dg-error "within this context" }
35 }
36
37 int main()
38 {
39     move_only t1 = test1();
40     move_only t2 = test2(move_only());
41     return 0;
42 }
43
44 bool b = true;