OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gdb-7.1/] [gdb/] [testsuite/] [gdb.cp/] [overload.cc] - Blame information for rev 231

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 227 jeremybenn
#include <stddef.h>
2
 
3
class foo {
4
public:
5
  foo  (int);
6
  foo  (int, const char *);
7
  foo  (foo&);
8
  ~foo ();
9
  void foofunc (int);
10
  void foofunc (int, signed char *);
11
  int ifoo;
12
  const char *ccpfoo;
13
 
14
int overload1arg (void);
15
int overload1arg (char);
16
int overload1arg (signed char);
17
int overload1arg (unsigned char);
18
int overload1arg (short);
19
int overload1arg (unsigned short);
20
int overload1arg (int);
21
int overload1arg (unsigned int);
22
int overload1arg (long);
23
int overload1arg (unsigned long);
24
int overload1arg (float);
25
int overload1arg (double);
26
 
27
int overloadfnarg (void);
28
int overloadfnarg (int);
29
int overloadfnarg (int, int (*) (int));
30
 
31
int overloadargs (int a1);
32
int overloadargs (int a1, int a2);
33
int overloadargs (int a1, int a2, int a3);
34
int overloadargs (int a1, int a2, int a3, int a4);
35
int overloadargs (int a1, int a2, int a3, int a4, int a5);
36
int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6);
37
int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7);
38
int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8);
39
int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9);
40
int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
41
                   int a8, int a9, int a10);
42
int overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
43
                   int a8, int a9, int a10, int a11);
44
 
45
};
46
 
47
struct K {
48
  static int staticoverload ();
49
  static int staticoverload (int);
50
  static int staticoverload (int, int);
51
};
52
 
53
namespace N {
54
  int nsoverload () { return 1; }
55
  int nsoverload (int x) { return x; }
56
  int nsoverload (int x, int y) { return x + y; }
57
};
58
 
59
int intToChar (char c) { return 297; }
60
 
61
void marker1()
62
{}
63
 
64
// Now test how overloading and namespaces interact.
65
 
66
class dummyClass {};
67
 
68
dummyClass dummyInstance;
69
 
70
int overloadNamespace(int i)
71
{
72
  return 1;
73
}
74
 
75
int overloadNamespace(dummyClass d)
76
{
77
  return 2;
78
}
79
 
80
namespace XXX {
81
  int overloadNamespace (char c)
82
  {
83
    return 3;
84
  }
85
 
86
  void marker2() {}
87
}
88
 
89
int main ()
90
{
91
    char arg2 = 2;
92
    signed char arg3 =3;
93
    unsigned char arg4 =4;
94
    short arg5 =5;
95
    unsigned short arg6 =6;
96
    int arg7 =7;
97
    unsigned int arg8 =8;
98
    long arg9 =9;
99
    unsigned long arg10 =10;
100
    float arg11 =100.0;
101
    double arg12 = 200.0;
102
 
103
    char *str = (char *) "A";
104
    foo foo_instance1(111);
105
    foo foo_instance2(222, str);
106
    foo foo_instance3(foo_instance2);
107
 
108
    // Some calls to ensure all the functions are emitted.
109
    K::staticoverload();
110
    K::staticoverload(2);
111
    K::staticoverload(2, 3);
112
    N::nsoverload();
113
    N::nsoverload(2);
114
    N::nsoverload(2, 3);
115
 
116
    #ifdef usestubs
117
       set_debug_traps();
118
       breakpoint();
119
    #endif
120
 
121
    overloadNamespace (1);
122
    overloadNamespace (dummyInstance);
123
    XXX::overloadNamespace ('a');
124
 
125
    // Verify that intToChar should work:
126
    intToChar(1);
127
 
128
    marker1(); // marker1-returns-here
129
    XXX::marker2(); // marker1-returns-here
130
    return 0;
131
}
132
 
133
foo::foo  (int i)                  { ifoo = i; ccpfoo = NULL; }
134
foo::foo  (int i, const char *ccp) { ifoo = i; ccpfoo = ccp; }
135
foo::foo  (foo& afoo)              { ifoo = afoo.ifoo; ccpfoo = afoo.ccpfoo;}
136
foo::~foo ()                       {}
137
 
138
 
139
/* Some functions to test overloading by varying one argument type. */
140
 
141
int foo::overload1arg (void)                {  return 1; }
142
int foo::overload1arg (char arg)            { arg = 0; return 2;}
143
int foo::overload1arg (signed char arg)     { arg = 0; return 3;}
144
int foo::overload1arg (unsigned char arg)   { arg = 0; return 4;}
145
int foo::overload1arg (short arg)           { arg = 0; return 5;}
146
int foo::overload1arg (unsigned short arg)  { arg = 0; return 6;}
147
int foo::overload1arg (int arg)             { arg = 0; return 7;}
148
int foo::overload1arg (unsigned int arg)    { arg = 0; return 8;}
149
int foo::overload1arg (long arg)            { arg = 0; return 9;}
150
int foo::overload1arg (unsigned long arg)   { arg = 0; return 10;}
151
int foo::overload1arg (float arg)           { arg = 0; return 11;}
152
int foo::overload1arg (double arg)          { arg = 0; return 12;}
153
 
154
/* Test to see that we can explicitly request overloaded functions
155
   with function pointers in the prototype. */
156
 
157
int foo::overloadfnarg (void) { return ifoo * 20; }
158
int foo::overloadfnarg (int arg) { arg = 0; return 13;}
159
int foo::overloadfnarg (int arg, int (*foo) (int))    { return foo(arg); }
160
 
161
/* Some functions to test overloading by varying argument count. */
162
 
163
int foo::overloadargs (int a1)
164
{ a1 = 0;
165
return 1;}
166
 
167
int foo::overloadargs (int a1, int a2)
168
{ a1 = a2 = 0;
169
return 2;}
170
 
171
int foo::overloadargs (int a1, int a2, int a3)
172
{ a1 = a2 = a3 = 0;
173
return 3;}
174
 
175
int foo::overloadargs (int a1, int a2, int a3, int a4)
176
{ a1 = a2 = a3 = a4 = 0;
177
return 4;}
178
 
179
int foo::overloadargs (int a1, int a2, int a3, int a4, int a5)
180
{ a1 = a2 = a3 = a4 = a5 = 0;
181
return 5;}
182
 
183
int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6)
184
{ a1 = a2 = a3 = a4 = a5 = a6 = 0;
185
return 6;}
186
 
187
int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7)
188
{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = 0;
189
return 7;}
190
 
191
int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
192
                   int a8)
193
{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = 0;
194
return 8;}
195
 
196
int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
197
                   int a8, int a9)
198
{
199
  a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = 0;
200
  return 9;
201
}
202
 
203
int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
204
                   int a8, int a9, int a10)
205
                        { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 =
206
                          a10 = 0; return 10;}
207
 
208
int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
209
                   int a8, int a9, int a10, int a11)
210
                        { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 =
211
                          a10 = a11 = 0; return 11;}
212
 
213
 
214
 
215
int K::staticoverload () { return 1; }
216
int K::staticoverload (int x) { return x; }
217
int K::staticoverload (int x, int y) { return x + y; }

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.