Debian Codegraph @

gcc/testsuite/g++.dg/cpp0x/rv1p.C

raw
1 // I, Howard Hinnant, hereby place this code in the public domain.
2
3 // Test overload resolution among reference types
4
5 // { dg-do compile { target c++11 } }
6 // { dg-skip-if "packed attribute missing for struct one/three/five/seven" { "epiphany-*-*" } }
7 // { dg-additional-options "-fno-ipa-icf" }
8
9 template <bool> struct sa;
10 template <> struct sa<true> {};
11
12 struct one {long x[1];};
13 struct two {long x[2];};
14 struct three {long x[3];};
15 struct four {long x[4];};
16 struct five {long x[5];};
17 struct six {long x[6];};
18 struct seven {long x[7];};
19 struct eight {long x[8];};
20
21 struct A
22 {
23 A();
24 A(const volatile A&&);
25 };
26
27 A source();
28 const A c_source();
29 volatile A v_source(); // { dg-warning "deprecated" "" { target c++2a } }
30 const volatile A cv_source(); // { dg-warning "deprecated" "" { target c++2a } }
31
32 // 1 at a time
33
34 one sink_1_1( A&);
35
36 int test1_1()
37 {
38 A a;
39 const A ca;
40 volatile A va;
41 const volatile A cva;
42 sa<sizeof(sink_1_1(a)) == 1 * sizeof(long)> t1;
43 return 0;
44 }
45
46 two sink_1_2(const A&);
47
48 int test1_2()
49 {
50 A a;
51 const A ca;
52 volatile A va;
53 const volatile A cva;
54 sa<sizeof(sink_1_2(a)) == 2 * sizeof(long)> t1;
55 sa<sizeof(sink_1_2(ca)) == 2 * sizeof(long)> t2;
56 sa<sizeof(sink_1_2(source())) == 2 * sizeof(long)> t5;
57 sa<sizeof(sink_1_2(c_source())) == 2 * sizeof(long)> t6;
58 return 0;
59 }
60
61 three sink_1_3(volatile A&);
62
63 int test1_3()
64 {
65 A a;
66 const A ca;
67 volatile A va;
68 const volatile A cva;
69 sa<sizeof(sink_1_3(a)) == 3 * sizeof(long)> t1;
70 sa<sizeof(sink_1_3(va)) == 3 * sizeof(long)> t3;
71 return 0;
72 }
73
74 four sink_1_4(const volatile A&);
75
76 int test1_4()
77 {
78 A a;
79 const A ca;
80 volatile A va;
81 const volatile A cva;
82 sa<sizeof(sink_1_4(a)) == 4 * sizeof(long)> t1;
83 sa<sizeof(sink_1_4(ca)) == 4 * sizeof(long)> t2;
84 sa<sizeof(sink_1_4(va)) == 4 * sizeof(long)> t3;
85 sa<sizeof(sink_1_4(cva)) == 4 * sizeof(long)> t4;
86 return 0;
87 }
88
89 five sink_1_5( A&&);
90
91 int test1_5()
92 {
93 A a;
94 const A ca;
95 volatile A va;
96 const volatile A cva;
97 sa<sizeof(sink_1_5(source())) == 5 * sizeof(long)> t5;
98 return 0;
99 }
100
101 six sink_1_6(const A&&);
102
103 int test1_6()
104 {
105 A a;
106 const A ca;
107 volatile A va;
108 const volatile A cva;
109 sa<sizeof(sink_1_6(source())) == 6 * sizeof(long)> t5;
110 sa<sizeof(sink_1_6(c_source())) == 6 * sizeof(long)> t6;
111 return 0;
112 }
113
114 seven sink_1_7(volatile A&&);
115
116 int test1_7()
117 {
118 A a;
119 const A ca;
120 volatile A va;
121 const volatile A cva;
122 sa<sizeof(sink_1_7(source())) == 7 * sizeof(long)> t5;
123 sa<sizeof(sink_1_7(v_source())) == 7 * sizeof(long)> t7;
124 return 0;
125 }
126
127 eight sink_1_8(const volatile A&&);
128
129 int test1_8()
130 {
131 A a;
132 const A ca;
133 volatile A va;
134 const volatile A cva;
135 sa<sizeof(sink_1_8(source())) == 8 * sizeof(long)> t5;
136 sa<sizeof(sink_1_8(c_source())) == 8 * sizeof(long)> t6;
137 sa<sizeof(sink_1_8(v_source())) == 8 * sizeof(long)> t7;
138 sa<sizeof(sink_1_8(cv_source())) == 8 * sizeof(long)> t8;
139 return 0;
140 }
141
142 int main()
143 {
144 return test1_1() + test1_2() + test1_3() + test1_4() +
145 test1_5() + test1_6() + test1_7() + test1_8();
146 }