OSDN Git Service

2008-02-14 Douglas Gregor <doug.gregor@gmail.com>
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / g++.dg / cpp0x / unnamed_refs.C
1 // I, Howard Hinnant, hereby place this code in the public domain.
2
3 // Test: Unamed rvalue references are treated as lvalues.
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 struct A {};
15
16 one foo(const A&) {return one();}
17 two foo(A&&)      {return two();}
18
19 A&& source() {static A a; return a;}
20
21 int test1()
22 {
23     sa<sizeof(foo(source())) == 2> t1;
24     return 0;
25 }
26
27 int main()
28 {
29     return test1();
30 }