aboutsummaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.cp/cplusfuncs.cc
blob: f4f78a626e1088e539f0f7859a845548704a4b6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
#include <stddef.h>

class foo {
public:
  foo  (int);
  foo  (int, const char *);
  foo  (foo&);
  ~foo ();

  void  operator *      (foo&);
  void  operator %      (foo&);
  void  operator -      (foo&);
  void  operator >>     (foo&);
  void  operator !=     (foo&);
  void  operator >      (foo&);
  void  operator >=     (foo&);
  void  operator |      (foo&);
  void  operator &&     (foo&);
  void  operator !      (void);
  void  operator ++     (int);
  void  operator =      (foo&);
  void  operator +=     (foo&);
  void  operator *=     (foo&);
  void  operator %=     (foo&);
  void  operator >>=    (foo&);
  void  operator |=     (foo&);
  void  operator ,      (foo&);
  void  operator /      (foo&);
  void  operator +      (foo&);
  void  operator <<     (foo&);
  void  operator ==     (foo&);
  void  operator <      (foo&);
  void  operator <=     (foo&);
  void  operator &      (foo&);
  void  operator ^      (foo&);
  void  operator ||     (foo&);
  void  operator ~      (void);
  void  operator --     (int);
  foo*  operator ->     (void);
  void  operator -=     (foo&);
  void  operator /=     (foo&);
  void  operator <<=    (foo&);
  void  operator &=     (foo&);
  void  operator ^=     (foo&);
  void  operator ->*    (foo&);
  void  operator []     (foo&);
  void  operator ()     (foo&);
  void* operator new    (size_t) throw ();
  void* operator new[]  (size_t) throw ();
  void  operator delete (void *);
  void  operator delete[] (void *);
  /**/  operator int    ();
  /**/  operator char*  ();

  int foofunc (int); // forced to have int return type, which is required
  int foofunc (int, signed char *); // forced to have int return type, which is required
  int ifoo;
  const char *ccpfoo;
};

#ifdef usestubs
extern "C" { 
   void set_debug_traps();
   void breakpoint();
};
#endif

int main () {
#ifdef usestubs
   set_debug_traps();
   breakpoint();
#endif
   int z=3;
}

foo::foo  (int i)                  { ifoo = i;}
foo::foo  (int i, const char *ccp) { ifoo = i; ccpfoo = ccp; }
foo::foo  (foo& afoo)              { afoo.ifoo = 0; }
foo::~foo ()                       {}

void  foo::operator *      (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator %      (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator -      (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator >>     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator !=     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator >      (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator >=     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator |      (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator &&     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator !      (void) {}
void  foo::operator ++     (int ival) { ival = 0; }
void  foo::operator =      (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator +=     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator *=     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator %=     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator >>=    (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator |=     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator ,      (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator /      (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator +      (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator <<     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator ==     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator <      (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator <=     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator &      (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator ^      (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator ||     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator ~      (void) {}
void  foo::operator --     (int ival) { ival = 0; }
foo*  foo::operator ->     (void) {return this;}
void  foo::operator -=     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator /=     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator <<=    (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator &=     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator ^=     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator ->*    (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator []     (foo& afoo) { afoo.ifoo = 0; }
void  foo::operator ()     (foo& afoo) { afoo.ifoo = 0; }
void* foo::operator new    (size_t ival) throw () { ival = 0; return 0; }
void* foo::operator new[]    (size_t ival) throw () { ival = 0; return 0; }
void  foo::operator delete (void *ptr) { ptr = 0; }
void  foo::operator delete[] (void *ptr) { ptr = 0; }
/**/  foo::operator int    () { return 0; }
/**/  foo::operator char*  () { return 0; }

/* Some functions to test overloading by varying one argument type. */

void overload1arg (void)		{          }
void overload1arg (char arg)		{ arg = 0; }
void overload1arg (signed char arg)	{ arg = 0; }
void overload1arg (unsigned char arg)	{ arg = 0; }
void overload1arg (short arg)		{ arg = 0; }
void overload1arg (unsigned short arg)	{ arg = 0; }
void overload1arg (int arg)		{ arg = 0; }
void overload1arg (unsigned int arg)	{ arg = 0; }
void overload1arg (long arg)		{ arg = 0; }
void overload1arg (unsigned long arg)	{ arg = 0; }
void overload1arg (float arg)		{ arg = 0; }
void overload1arg (double arg)		{ arg = 0; }

/* Some functions to test overloading by varying argument count. */

void overloadargs (int a1)				{ a1 = 0; }
void overloadargs (int a1, int a2)			{ a1 = a2 = 0; }
void overloadargs (int a1, int a2, int a3)		{ a1 = a2 = a3 = 0; }
void overloadargs (int a1, int a2, int a3, int a4)
			{ a1 = a2 = a3 = a4 = 0; }
void overloadargs (int a1, int a2, int a3, int a4, int a5)
			{ a1 = a2 = a3 = a4 = a5 = 0; }
void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6)
			{ a1 = a2 = a3 = a4 = a5 = a6 = 0; }
void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7)
			{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = 0; }
void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
		   int a8)
			{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = 0; }
void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
		   int a8, int a9)
			{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = 0; }
void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
		   int a8, int a9, int a10)
			{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 =
			  a10 = 0; }
void overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
		   int a8, int a9, int a10, int a11)
			{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 =
			  a10 = a11 == 0; }

/* Some hairy function definitions.
   Use typedefs to help maintain sanity. */

typedef int   (*PFPc_i)(char *);
typedef short (*PFPl_s)(long *);
typedef short (*PFPc_s)(char *);
typedef int   (*PFl_i)(long);
typedef PFl_i (*PFPc_PFl_i)(char *);
typedef PFl_i (*PFPi_PFl_i)(int *);
typedef PFl_i (*PFPFPc_i_PFl_i)(PFPc_i);
typedef PFl_i (*PFs_PFl_i)(short);
typedef int   (*PFPFPl_s_i)(PFPl_s);
typedef int   (*PFPFPc_s_i)(PFPc_s);

PFs_PFl_i hairyfunc1 (int arg)			{ arg = 0; return 0; }
int       hairyfunc2 (PFPc_i arg)		{ arg = 0; return 0; }
int	  hairyfunc3 (PFPFPl_s_i arg)		{ arg = 0; return 0; }
int	  hairyfunc4 (PFPFPc_s_i arg)		{ arg = 0; return 0; }
int	  hairyfunc5 (PFPc_PFl_i arg)		{ arg = 0; return 0; }
int	  hairyfunc6 (PFPi_PFl_i arg)		{ arg = 0; return 0; }
int	  hairyfunc7 (PFPFPc_i_PFl_i arg)	{ arg = 0; return 0; }

/* gdb has two demanglers (one for g++ 2.95, one for g++ 3).
   These marker functions help me figure out which demangler is in use. */

char *	dm_type_char_star (char * p)		{ return p; }
int	dm_type_foo_ref (foo & foo)		{ return foo.ifoo; }
int *	dm_type_int_star (int * p)		{ return p; }
long *	dm_type_long_star (long * p)		{ return p; }
int	dm_type_unsigned_int (unsigned int i)	{ return i; }
int	dm_type_void (void)			{ return 0; }
void *	dm_type_void_star (void * p)		{ return p; }