Fix crash when exiting TUI with gdb -tui
[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
cee00f17
GB
94static int dummy;
95
6a3c6ee4
PA
96struct test_op_new
97{
98 void *operator new (size_t);
99};
100
101void *
102test_op_new::operator new (size_t)
103{
cee00f17 104 return &dummy;
6a3c6ee4
PA
105}
106
107/* Code for operator delete tests. */
108
109struct test_op_delete
110{
111 void operator delete (void *);
112};
113
114void
115test_op_delete::operator delete (void *)
116{
117}
118
119/* Code for operator new[] tests. */
120
121struct test_op_new_array
122{
123 void *operator new[] (size_t);
124};
125
126void *
127test_op_new_array::operator new[] (size_t)
128{
cee00f17 129 return &dummy;
6a3c6ee4
PA
130}
131
132/* Code for operator delete[] tests. */
133
134struct test_op_delete_array
135{
136 void operator delete[] (void *);
137};
138
139void
140test_op_delete_array::operator delete[] (void *)
141{
142}
143
144/* Code for user-defined conversion tests. */
145
146struct test_op_conversion_res;
147
148struct test_op_conversion
149{
150 operator const volatile test_op_conversion_res **() const volatile;
151};
152
153test_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
161struct test_op_assign
162{
163 test_op_assign operator= (const test_op_assign &);
164};
165
166test_op_assign
167test_op_assign::operator= (const test_op_assign &)
168{
169 return test_op_assign ();
170}
171
172/* Code for the arrow operator tests. */
173
174struct test_op_arrow
175{
176 test_op_arrow operator-> ();
177};
178
179test_op_arrow
180test_op_arrow::operator-> ()
181{
182 return test_op_arrow ();
183}
184
185/* Code for the logical/arithmetic operators tests. */
186
187struct 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
199GEN_OP (PLUS_A, += (E, E) )
200GEN_OP (PLUS, + (E, E) )
201GEN_OP (MINUS_A, -= (E, E) )
202GEN_OP (MINUS, - (E, E) )
203GEN_OP (MOD_A, %= (E, E) )
204GEN_OP (MOD, % (E, E) )
205GEN_OP (EQ, == (E, E) )
206GEN_OP (NEQ, != (E, E) )
207GEN_OP (LAND, && (E, E) )
208GEN_OP (LOR, || (E, E) )
209GEN_OP (SL_A, <<= (E, E) )
210GEN_OP (SR_A, >>= (E, E) )
211GEN_OP (SL, << (E, E) )
212GEN_OP (SR, >> (E, E) )
213GEN_OP (OE, |= (E, E) )
214GEN_OP (BIT_O, | (E, E) )
215GEN_OP (XOR_A, ^= (E, E) )
216GEN_OP (XOR, ^ (E, E) )
217GEN_OP (BIT_AND_A, &= (E, E) )
218GEN_OP (BIT_AND, & (E, E) )
219GEN_OP (LT, < (E, E) )
220GEN_OP (LTE, <= (E, E) )
221GEN_OP (GTE, >= (E, E) )
222GEN_OP (GT, > (E, E) )
223GEN_OP (MUL_A, *= (E, E) )
224GEN_OP (MUL, * (E, E) )
225GEN_OP (DIV_A, /= (E, E) )
226GEN_OP (DIV, / (E, E) )
227GEN_OP (NEG, ~ (E) )
228GEN_OP (NOT, ! (E) )
229GEN_OP (PRE_INC, ++ (E) )
230GEN_OP (POST_INC, ++ (E, int) )
231GEN_OP (PRE_DEC, -- (E) )
232GEN_OP (POST_DEC, -- (E, int) )
233GEN_OP (COMMA, , (E, E) )
234
235int
236main ()
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}
This page took 0.606316 seconds and 4 git commands to generate.