Update copyright year range in all GDB files.
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.linespec / cpls-ops.cc
CommitLineData
6a3c6ee4
PA
1/* This testcase is part of GDB, the GNU debugger.
2
b811d2c2 3 Copyright 2017-2020 Free Software Foundation, Inc.
6a3c6ee4
PA
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
22struct test_unique_op_call
23{
24 void operator() (int);
25};
26
27void
28test_unique_op_call::operator() (int)
29{}
30
31struct 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
41void
42test_op_call::operator() (int)
43{}
44
45void
46test_op_call::operator() ()
47{}
48
49void
50test_op_call::operator() (long)
51{}
52
53template<typename T>
54void
55test_op_call::operator() (T *t)
56{
57}
58
59/* Code for operator[] tests. */
60
61struct test_unique_op_array
62{
63 void operator[] (int);
64};
65
66void
67test_unique_op_array::operator[] (int)
68{}
69
70struct test_op_array
71{
72 void operator[] (int);
73 void operator[] (long);
74
75 template<typename T>
76 void operator[] (T *);
77};
78
79void
80test_op_array::operator[] (int)
81{}
82
83void
84test_op_array::operator[] (long)
85{}
86
87template<typename T>
88void
89test_op_array::operator[] (T *t)
90{}
91
92/* Code for operator new tests. */
93
94struct test_op_new
95{
96 void *operator new (size_t);
97};
98
99void *
100test_op_new::operator new (size_t)
101{
102 return NULL;
103}
104
105/* Code for operator delete tests. */
106
107struct test_op_delete
108{
109 void operator delete (void *);
110};
111
112void
113test_op_delete::operator delete (void *)
114{
115}
116
117/* Code for operator new[] tests. */
118
119struct test_op_new_array
120{
121 void *operator new[] (size_t);
122};
123
124void *
125test_op_new_array::operator new[] (size_t)
126{
127 return NULL;
128}
129
130/* Code for operator delete[] tests. */
131
132struct test_op_delete_array
133{
134 void operator delete[] (void *);
135};
136
137void
138test_op_delete_array::operator delete[] (void *)
139{
140}
141
142/* Code for user-defined conversion tests. */
143
144struct test_op_conversion_res;
145
146struct test_op_conversion
147{
148 operator const volatile test_op_conversion_res **() const volatile;
149};
150
151test_op_conversion::operator const volatile test_op_conversion_res **()
152 const volatile
153{
154 return NULL;
155}
156
157/* Code for the assignment operator tests. */
158
159struct test_op_assign
160{
161 test_op_assign operator= (const test_op_assign &);
162};
163
164test_op_assign
165test_op_assign::operator= (const test_op_assign &)
166{
167 return test_op_assign ();
168}
169
170/* Code for the arrow operator tests. */
171
172struct test_op_arrow
173{
174 test_op_arrow operator-> ();
175};
176
177test_op_arrow
178test_op_arrow::operator-> ()
179{
180 return test_op_arrow ();
181}
182
183/* Code for the logical/arithmetic operators tests. */
184
185struct E
186{
187};
188
189#define GEN_OP(NS, ...) \
190 namespace test_ops { \
191 void operator __VA_ARGS__ {} \
192 } \
193 namespace test_op_ ## NS { \
194 void operator __VA_ARGS__ {} \
195 }
196
197GEN_OP (PLUS_A, += (E, E) )
198GEN_OP (PLUS, + (E, E) )
199GEN_OP (MINUS_A, -= (E, E) )
200GEN_OP (MINUS, - (E, E) )
201GEN_OP (MOD_A, %= (E, E) )
202GEN_OP (MOD, % (E, E) )
203GEN_OP (EQ, == (E, E) )
204GEN_OP (NEQ, != (E, E) )
205GEN_OP (LAND, && (E, E) )
206GEN_OP (LOR, || (E, E) )
207GEN_OP (SL_A, <<= (E, E) )
208GEN_OP (SR_A, >>= (E, E) )
209GEN_OP (SL, << (E, E) )
210GEN_OP (SR, >> (E, E) )
211GEN_OP (OE, |= (E, E) )
212GEN_OP (BIT_O, | (E, E) )
213GEN_OP (XOR_A, ^= (E, E) )
214GEN_OP (XOR, ^ (E, E) )
215GEN_OP (BIT_AND_A, &= (E, E) )
216GEN_OP (BIT_AND, & (E, E) )
217GEN_OP (LT, < (E, E) )
218GEN_OP (LTE, <= (E, E) )
219GEN_OP (GTE, >= (E, E) )
220GEN_OP (GT, > (E, E) )
221GEN_OP (MUL_A, *= (E, E) )
222GEN_OP (MUL, * (E, E) )
223GEN_OP (DIV_A, /= (E, E) )
224GEN_OP (DIV, / (E, E) )
225GEN_OP (NEG, ~ (E) )
226GEN_OP (NOT, ! (E) )
227GEN_OP (PRE_INC, ++ (E) )
228GEN_OP (POST_INC, ++ (E, int) )
229GEN_OP (PRE_DEC, -- (E) )
230GEN_OP (POST_DEC, -- (E, int) )
231GEN_OP (COMMA, , (E, E) )
232
233int
234main ()
235{
236 test_op_call opcall;
237 opcall ();
238 opcall (1);
239 opcall (1l);
240 opcall ((int *) 0);
241
242 test_unique_op_call opcall2;
243 opcall2 (1);
244
245 test_op_array op_array;
246 op_array[1];
247 op_array[1l];
248 op_array[(int *) 0];
249
250 test_unique_op_array unique_op_array;
251 unique_op_array[1];
252
253 return 0;
254}
This page took 0.278554 seconds and 4 git commands to generate.