Merged r158907 through r159238 into branch.
[official-gcc.git] / gcc / testsuite / g++.dg / cpp0x / rv1p.C
blobb2770ef33d5cca86a84998e19efe64a4c8c899de
1 // I, Howard Hinnant, hereby place this code in the public domain.
3 // Test overload resolution among reference types
5 // { dg-do compile }
6 // { dg-options "-std=c++0x" }
8 template <bool> struct sa;
9 template <> struct sa<true> {};
11 struct one   {char x[1];};
12 struct two   {char x[2];};
13 struct three {char x[3];};
14 struct four  {char x[4];};
15 struct five  {char x[5];};
16 struct six   {char x[6];};
17 struct seven {char x[7];};
18 struct eight {char x[8];};
20 struct A
22     A();
23     A(const volatile A&&);
26                A    source();
27 const          A  c_source();
28       volatile A  v_source();
29 const volatile A cv_source();
31 // 1 at a time
33 one   sink_1_1(               A&);
35 int test1_1()
37                    A a;
38     const          A ca = a;
39           volatile A va;
40     const volatile A cva = a;
41     sa<sizeof(sink_1_1(a))           == 1> t1;
42     return 0;
45 two   sink_1_2(const          A&);
47 int test1_2()
49                    A a;
50     const          A ca = a;
51           volatile A va;
52     const volatile A cva = a;
53     sa<sizeof(sink_1_2(a))           == 2> t1;
54     sa<sizeof(sink_1_2(ca))          == 2> t2;
55     sa<sizeof(sink_1_2(source()))    == 2> t5;
56     sa<sizeof(sink_1_2(c_source()))  == 2> t6;
57     return 0;
60 three sink_1_3(volatile       A&);
62 int test1_3()
64                    A a;
65     const          A ca = a;
66           volatile A va;
67     const volatile A cva = a;
68     sa<sizeof(sink_1_3(a))           == 3> t1;
69     sa<sizeof(sink_1_3(va))          == 3> t3;
70     return 0;
73 four  sink_1_4(const volatile A&);
75 int test1_4()
77                    A a;
78     const          A ca = a;
79           volatile A va;
80     const volatile A cva = a;
81     sa<sizeof(sink_1_4(a))           == 4> t1;
82     sa<sizeof(sink_1_4(ca))          == 4> t2;
83     sa<sizeof(sink_1_4(va))          == 4> t3;
84     sa<sizeof(sink_1_4(cva))         == 4> t4;
85     return 0;
88 five  sink_1_5(               A&&);
90 int test1_5()
92                    A a;
93     const          A ca = a;
94           volatile A va;
95     const volatile A cva = a;
96     sa<sizeof(sink_1_5(source()))    == 5> t5;
97     return 0;
100 six   sink_1_6(const          A&&);
102 int test1_6()
104                    A a;
105     const          A ca = a;
106           volatile A va;
107     const volatile A cva = a;
108     sa<sizeof(sink_1_6(source()))    == 6> t5;
109     sa<sizeof(sink_1_6(c_source()))  == 6> t6;
110     return 0;
113 seven sink_1_7(volatile       A&&);
115 int test1_7()
117                    A a;
118     const          A ca = a;
119           volatile A va;
120     const volatile A cva = a;
121     sa<sizeof(sink_1_7(source()))    == 7> t5;
122     sa<sizeof(sink_1_7(v_source()))  == 7> t7;
123     return 0;
126 eight sink_1_8(const volatile A&&);
128 int test1_8()
130                    A a;
131     const          A ca = a;
132           volatile A va;
133     const volatile A cva = a;
134     sa<sizeof(sink_1_8(source()))    == 8> t5;
135     sa<sizeof(sink_1_8(c_source()))  == 8> t6;
136     sa<sizeof(sink_1_8(v_source()))  == 8> t7;
137     sa<sizeof(sink_1_8(cv_source())) == 8> t8;
138     return 0;
141 int main()
143     return test1_1() + test1_2() + test1_3() + test1_4() +
144            test1_5() + test1_6() + test1_7() + test1_8();