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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [testsuite/] [gdb.c++/] [overload.cc] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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