* Contribute CGEN simulator build support code.
[binutils-gdb.git] / gdb / testsuite / gdb.c++ / userdef.cc
blob9ad6c869b6ecca62d5dc875a69bc03b43b9ba8b4
1 #include <iostream.h>
3 void marker1()
5 return;
8 class A1 {
9 int x;
10 int y;
12 friend ostream& operator<<(ostream& outs, A1 one);
14 public:
16 A1(int a, int b)
18 x=a;
19 y=b;
22 A1 operator+=(int value);
23 A1 operator+(const A1&);
24 A1 operator-(const A1&);
25 A1 operator%(const A1&);
26 int operator==(const A1&);
27 int operator!=(const A1&);
28 int operator&&(const A1&);
29 int operator||(const A1&);
30 A1 operator<<(int);
31 A1 operator>>(int);
32 A1 operator|(const A1&);
33 A1 operator^(const A1&);
34 A1 operator&(const A1&);
35 int operator<(const A1&);
36 int operator<=(const A1&);
37 int operator>=(const A1&);
38 int operator>(const A1&);
39 A1 operator*(const A1&);
40 A1 operator/(const A1&);
41 A1 operator=(const A1&);
43 A1 operator~();
44 A1 operator-();
45 int operator!();
46 A1 operator++();
47 A1 operator++(int);
48 A1 operator--();
49 A1 operator--(int);
54 A1 A1::operator+(const A1& second)
56 A1 sum(0,0);
57 sum.x = x + second.x;
58 sum.y = y + second.y;
60 return (sum);
63 A1 A1::operator*(const A1& second)
65 A1 product(0,0);
66 product.x = this->x * second.x;
67 product.y = this->y * second.y;
69 return product;
72 A1 A1::operator-(const A1& second)
74 A1 diff(0,0);
75 diff.x = x - second.x;
76 diff.y = y - second.y;
78 return diff;
81 A1 A1::operator/(const A1& second)
83 A1 div(0,0);
84 div.x = x / second.x;
85 div.y = y / second.y;
87 return div;
90 A1 A1::operator%(const A1& second)
92 A1 rem(0,0);
93 rem.x = x % second.x;
94 rem.y = y % second.y;
96 return rem;
99 int A1::operator==(const A1& second)
101 int a = (x == second.x);
102 int b = (y == second.y);
104 return (a && b);
107 int A1::operator!=(const A1& second)
109 int a = (x != second.x);
110 int b = (y != second.y);
112 return (a || b);
115 int A1::operator&&(const A1& second)
117 return ( x && second.x);
120 int A1::operator||(const A1& second)
122 return ( x || second.x);
125 A1 A1::operator<<(int value)
127 A1 lshft(0,0);
128 lshft.x = x << value;
129 lshft.y = y << value;
131 return lshft;
134 A1 A1::operator>>(int value)
136 A1 rshft(0,0);
137 rshft.x = x >> value;
138 rshft.y = y >> value;
140 return rshft;
143 A1 A1::operator|(const A1& second)
145 A1 abitor(0,0);
146 abitor.x = x | second.x;
147 abitor.y = y | second.y;
149 return abitor;
152 A1 A1::operator^(const A1& second)
154 A1 axor(0,0);
155 axor.x = x ^ second.x;
156 axor.y = y ^ second.y;
158 return axor;
161 A1 A1::operator&(const A1& second)
163 A1 abitand(0,0);
164 abitand.x = x & second.x;
165 abitand.y = y & second.y;
167 return abitand;
170 int A1::operator<(const A1& second)
172 A1 b(0,0);
173 b.x = 3;
174 return (x < second.x);
177 int A1::operator<=(const A1& second)
179 return (x <= second.x);
182 int A1::operator>=(const A1& second)
184 return (x >= second.x);
187 int A1::operator>(const A1& second)
189 return (x > second.x);
192 int A1::operator!(void)
194 return (!x);
197 A1 A1::operator-(void)
199 A1 neg(0,0);
200 neg.x = -x;
201 neg.y = -y;
203 return (neg);
206 A1 A1::operator~(void)
208 A1 acompl(0,0);
209 acompl.x = ~x;
210 acompl.y = ~y;
212 return (acompl);
215 A1 A1::operator++() // pre increment
217 x = x +1;
219 return (*this);
222 A1 A1::operator++(int) // post increment
224 y = y +1;
226 return (*this);
229 A1 A1::operator--() // pre decrement
231 x = x -1;
233 return (*this);
236 A1 A1::operator--(int) // post decrement
238 y = y -1;
240 return (*this);
244 A1 A1::operator=(const A1& second)
247 x = second.x;
248 y = second.y;
250 return (*this);
253 A1 A1::operator+=(int value)
256 x += value;
257 y += value;
259 return (*this);
262 ostream& operator<<(ostream& outs, A1 one)
264 return (outs << endl << "x = " << one.x << endl << "y = " << one.y << endl << "-------" << endl);
267 int main (void)
269 A1 one(2,3);
270 A1 two(4,5);
271 A1 three(0,0);
272 int val;
274 marker1();
275 cout << one;
276 cout << two;
277 three = one + two;
278 cout << "+ " << three;
279 three = one - two;
280 cout << "- " << three;
281 three = one * two;
282 cout <<"* " << three;
283 three = one / two;
284 cout << "/ " << three;
285 three = one % two;
286 cout << "% " << three;
287 three = one | two;
288 cout << "| " <<three;
289 three = one ^ two;
290 cout << "^ " <<three;
291 three = one & two;
292 cout << "& "<< three;
294 val = one && two;
295 cout << "&& " << val << endl << "-----"<<endl;
296 val = one || two;
297 cout << "|| " << val << endl << "-----"<<endl;
298 val = one == two;
299 cout << " == " << val << endl << "-----"<<endl;
300 val = one != two;
301 cout << "!= " << val << endl << "-----"<<endl;
302 val = one >= two;
303 cout << ">= " << val << endl << "-----"<<endl;
304 val = one <= two;
305 cout << "<= " << val << endl << "-----"<<endl;
306 val = one < two;
307 cout << "< " << val << endl << "-----"<<endl;
308 val = one > two;
309 cout << "> " << val << endl << "-----"<<endl;
311 three = one << 2;
312 cout << "lsh " << three;
313 three = one >> 2;
314 cout << "rsh " << three;
316 three = one;
317 cout << " = "<< three;
318 three += 5;
319 cout << " += "<< three;
321 val = (!one);
322 cout << "! " << val << endl << "-----"<<endl;
323 three = (-one);
324 cout << "- " << three;
325 three = (~one);
326 cout << " ~" << three;
327 three++;
328 cout << "postinc " << three;
329 three--;
330 cout << "postdec " << three;
332 --three;
333 cout << "predec " << three;
334 ++three;
335 cout << "preinc " << three;
337 return 0;