]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/testsuite/gdb.linespec/cpls-ops.cc
Update copyright year range in header of all files managed by GDB
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.linespec / cpls-ops.cc
1 /* This testcase is part of GDB, the GNU debugger.
2
3 Copyright 2017-2024 Free Software Foundation, Inc.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17
18 #include <cstddef>
19
20 /* Code for operator() tests. */
21
22 struct test_unique_op_call
23 {
24 void operator() (int);
25 };
26
27 void
28 test_unique_op_call::operator() (int)
29 {}
30
31 struct test_op_call
32 {
33 void operator() ();
34 void operator() (int);
35 void operator() (long);
36
37 template<typename T>
38 void operator() (T *);
39 };
40
41 void
42 test_op_call::operator() (int)
43 {}
44
45 void
46 test_op_call::operator() ()
47 {}
48
49 void
50 test_op_call::operator() (long)
51 {}
52
53 template<typename T>
54 void
55 test_op_call::operator() (T *t)
56 {
57 }
58
59 /* Code for operator[] tests. */
60
61 struct test_unique_op_array
62 {
63 void operator[] (int);
64 };
65
66 void
67 test_unique_op_array::operator[] (int)
68 {}
69
70 struct test_op_array
71 {
72 void operator[] (int);
73 void operator[] (long);
74
75 template<typename T>
76 void operator[] (T *);
77 };
78
79 void
80 test_op_array::operator[] (int)
81 {}
82
83 void
84 test_op_array::operator[] (long)
85 {}
86
87 template<typename T>
88 void
89 test_op_array::operator[] (T *t)
90 {}
91
92 /* Code for operator new tests. */
93
94 static int dummy;
95
96 struct test_op_new
97 {
98 void *operator new (size_t);
99 };
100
101 void *
102 test_op_new::operator new (size_t)
103 {
104 return &dummy;
105 }
106
107 /* Code for operator delete tests. */
108
109 struct test_op_delete
110 {
111 void operator delete (void *);
112 };
113
114 void
115 test_op_delete::operator delete (void *)
116 {
117 }
118
119 /* Code for operator new[] tests. */
120
121 struct test_op_new_array
122 {
123 void *operator new[] (size_t);
124 };
125
126 void *
127 test_op_new_array::operator new[] (size_t)
128 {
129 return &dummy;
130 }
131
132 /* Code for operator delete[] tests. */
133
134 struct test_op_delete_array
135 {
136 void operator delete[] (void *);
137 };
138
139 void
140 test_op_delete_array::operator delete[] (void *)
141 {
142 }
143
144 /* Code for user-defined conversion tests. */
145
146 struct test_op_conversion_res;
147
148 struct test_op_conversion
149 {
150 operator const volatile test_op_conversion_res **() const volatile;
151 };
152
153 test_op_conversion::operator const volatile test_op_conversion_res **()
154 const volatile
155 {
156 return NULL;
157 }
158
159 /* Code for the assignment operator tests. */
160
161 struct test_op_assign
162 {
163 test_op_assign operator= (const test_op_assign &);
164 };
165
166 test_op_assign
167 test_op_assign::operator= (const test_op_assign &)
168 {
169 return test_op_assign ();
170 }
171
172 /* Code for the arrow operator tests. */
173
174 struct test_op_arrow
175 {
176 test_op_arrow operator-> ();
177 };
178
179 test_op_arrow
180 test_op_arrow::operator-> ()
181 {
182 return test_op_arrow ();
183 }
184
185 /* Code for the logical/arithmetic operators tests. */
186
187 struct E
188 {
189 };
190
191 #define GEN_OP(NS, ...) \
192 namespace test_ops { \
193 void operator __VA_ARGS__ {} \
194 } \
195 namespace test_op_ ## NS { \
196 void operator __VA_ARGS__ {} \
197 }
198
199 GEN_OP (PLUS_A, += (E, E) )
200 GEN_OP (PLUS, + (E, E) )
201 GEN_OP (MINUS_A, -= (E, E) )
202 GEN_OP (MINUS, - (E, E) )
203 GEN_OP (MOD_A, %= (E, E) )
204 GEN_OP (MOD, % (E, E) )
205 GEN_OP (EQ, == (E, E) )
206 GEN_OP (NEQ, != (E, E) )
207 GEN_OP (LAND, && (E, E) )
208 GEN_OP (LOR, || (E, E) )
209 GEN_OP (SL_A, <<= (E, E) )
210 GEN_OP (SR_A, >>= (E, E) )
211 GEN_OP (SL, << (E, E) )
212 GEN_OP (SR, >> (E, E) )
213 GEN_OP (OE, |= (E, E) )
214 GEN_OP (BIT_O, | (E, E) )
215 GEN_OP (XOR_A, ^= (E, E) )
216 GEN_OP (XOR, ^ (E, E) )
217 GEN_OP (BIT_AND_A, &= (E, E) )
218 GEN_OP (BIT_AND, & (E, E) )
219 GEN_OP (LT, < (E, E) )
220 GEN_OP (LTE, <= (E, E) )
221 GEN_OP (GTE, >= (E, E) )
222 GEN_OP (GT, > (E, E) )
223 GEN_OP (MUL_A, *= (E, E) )
224 GEN_OP (MUL, * (E, E) )
225 GEN_OP (DIV_A, /= (E, E) )
226 GEN_OP (DIV, / (E, E) )
227 GEN_OP (NEG, ~ (E) )
228 GEN_OP (NOT, ! (E) )
229 GEN_OP (PRE_INC, ++ (E) )
230 GEN_OP (POST_INC, ++ (E, int) )
231 GEN_OP (PRE_DEC, -- (E) )
232 GEN_OP (POST_DEC, -- (E, int) )
233 GEN_OP (COMMA, , (E, E) )
234
235 int
236 main ()
237 {
238 test_op_call opcall;
239 opcall ();
240 opcall (1);
241 opcall (1l);
242 opcall ((int *) 0);
243
244 test_unique_op_call opcall2;
245 opcall2 (1);
246
247 test_op_array op_array;
248 op_array[1];
249 op_array[1l];
250 op_array[(int *) 0];
251
252 test_unique_op_array unique_op_array;
253 unique_op_array[1];
254
255 return 0;
256 }