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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gdb-6.8/] [gdb/] [testsuite/] [gdb.cp/] [overload.cc] - Blame information for rev 841

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

Line No. Rev Author Line
1 24 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
 
48
int intToChar (char c)
49
{
50
  return 297;
51
}
52
 
53
void marker1()
54
{}
55
 
56
// Now test how overloading and namespaces interact.
57
 
58
class dummyClass {};
59
 
60
dummyClass dummyInstance;
61
 
62
int overloadNamespace(int i)
63
{
64
  return 1;
65
}
66
 
67
int overloadNamespace(dummyClass d)
68
{
69
  return 2;
70
}
71
 
72
namespace XXX {
73
  int overloadNamespace (char c)
74
  {
75
    return 3;
76
  }
77
 
78
  void marker2() {}
79
}
80
 
81
int main ()
82
{
83
    char arg2 = 2;
84
    signed char arg3 =3;
85
    unsigned char arg4 =4;
86
    short arg5 =5;
87
    unsigned short arg6 =6;
88
    int arg7 =7;
89
    unsigned int arg8 =8;
90
    long arg9 =9;
91
    unsigned long arg10 =10;
92
    float arg11 =100.0;
93
    double arg12 = 200.0;
94
 
95
    char *str = (char *) "A";
96
    foo foo_instance1(111);
97
    foo foo_instance2(222, str);
98
    foo foo_instance3(foo_instance2);
99
 
100
    #ifdef usestubs
101
       set_debug_traps();
102
       breakpoint();
103
    #endif
104
 
105
    // Verify that intToChar should work:
106
    intToChar(1);
107
 
108
    marker1(); // marker1-returns-here
109
    XXX::marker2(); // marker1-returns-here
110
    return 0;
111
}
112
 
113
foo::foo  (int i)                  { ifoo = i; ccpfoo = NULL; }
114
foo::foo  (int i, const char *ccp) { ifoo = i; ccpfoo = ccp; }
115
foo::foo  (foo& afoo)              { ifoo = afoo.ifoo; ccpfoo = afoo.ccpfoo;}
116
foo::~foo ()                       {}
117
 
118
 
119
/* Some functions to test overloading by varying one argument type. */
120
 
121
int foo::overload1arg (void)                {  return 1; }
122
int foo::overload1arg (char arg)            { arg = 0; return 2;}
123
int foo::overload1arg (signed char arg)     { arg = 0; return 3;}
124
int foo::overload1arg (unsigned char arg)   { arg = 0; return 4;}
125
int foo::overload1arg (short arg)           { arg = 0; return 5;}
126
int foo::overload1arg (unsigned short arg)  { arg = 0; return 6;}
127
int foo::overload1arg (int arg)             { arg = 0; return 7;}
128
int foo::overload1arg (unsigned int arg)    { arg = 0; return 8;}
129
int foo::overload1arg (long arg)            { arg = 0; return 9;}
130
int foo::overload1arg (unsigned long arg)   { arg = 0; return 10;}
131
int foo::overload1arg (float arg)           { arg = 0; return 11;}
132
int foo::overload1arg (double arg)          { arg = 0; return 12;}
133
 
134
/* Test to see that we can explicitly request overloaded functions
135
   with function pointers in the prototype. */
136
 
137
int foo::overloadfnarg (void) { return ifoo * 20; }
138
int foo::overloadfnarg (int arg) { arg = 0; return 13;}
139
int foo::overloadfnarg (int arg, int (*foo) (int))    { return foo(arg); }
140
 
141
/* Some functions to test overloading by varying argument count. */
142
 
143
int foo::overloadargs (int a1)
144
{ a1 = 0;
145
return 1;}
146
 
147
int foo::overloadargs (int a1, int a2)
148
{ a1 = a2 = 0;
149
return 2;}
150
 
151
int foo::overloadargs (int a1, int a2, int a3)
152
{ a1 = a2 = a3 = 0;
153
return 3;}
154
 
155
int foo::overloadargs (int a1, int a2, int a3, int a4)
156
{ a1 = a2 = a3 = a4 = 0;
157
return 4;}
158
 
159
int foo::overloadargs (int a1, int a2, int a3, int a4, int a5)
160
{ a1 = a2 = a3 = a4 = a5 = 0;
161
return 5;}
162
 
163
int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6)
164
{ a1 = a2 = a3 = a4 = a5 = a6 = 0;
165
return 6;}
166
 
167
int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7)
168
{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = 0;
169
return 7;}
170
 
171
int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
172
                   int a8)
173
{ a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = 0;
174
return 8;}
175
 
176
int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
177
                   int a8, int a9)
178
{
179
  a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 = 0;
180
  return 9;
181
}
182
 
183
int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
184
                   int a8, int a9, int a10)
185
                        { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 =
186
                          a10 = 0; return 10;}
187
 
188
int foo::overloadargs (int a1, int a2, int a3, int a4, int a5, int a6, int a7,
189
                   int a8, int a9, int a10, int a11)
190
                        { a1 = a2 = a3 = a4 = a5 = a6 = a7 = a8 = a9 =
191
                          a10 = a11 = 0; return 11;}
192
 
193
 
194
 

powered by: WebSVN 2.1.0

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