gdb/testsuite/
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.cp / namespace.cc
CommitLineData
66a55e80
DB
1namespace AAA {
2 char c;
3 int i;
4 int A_xyzq (int);
5 char xyzq (char);
6 class inA {
7 public:
8 int xx;
9 int fum (int);
10 };
11};
12
13int AAA::inA::fum (int i)
14{
15 return 10 + i;
16}
17
18namespace BBB {
19 char c;
20 int i;
21 int B_xyzq (int);
22 char xyzq (char);
23
24 namespace CCC {
25 char xyzq (char);
26 };
27
28 class Class {
29 public:
30 char xyzq (char);
31 int dummy;
32 };
33};
34
35int AAA::A_xyzq (int x)
36{
37 return 2 * x;
38}
39
40char AAA::xyzq (char c)
41{
42 return 'a';
43}
44
45
46int BBB::B_xyzq (int x)
47{
48 return 3 * x;
49}
50
51char BBB::xyzq (char c)
52{
53 return 'b';
54}
55
56char BBB::CCC::xyzq (char c)
57{
58 return 'z';
59}
60
61char BBB::Class::xyzq (char c)
62{
63 return 'o';
64}
65
66void marker1(void)
67{
68 return;
69}
70
1fcb5155
DC
71namespace
72{
73 int X = 9;
74
75 namespace G
76 {
77 int Xg = 10;
79c2c32d
DC
78
79 namespace
80 {
81 int XgX = 11;
82 }
1fcb5155
DC
83 }
84}
85
86namespace C
87{
88 int c = 1;
89 int shadow = 12;
90
63d06c5c
DC
91 class CClass {
92 public:
93 int x;
94 class NestedClass {
95 public:
96 int y;
97 };
98 };
99
37fc574a
DC
100 void ensureRefs () {
101 // NOTE (2004-04-23, carlton): This function is here only to make
102 // sure that GCC 3.4 outputs debug info for these classes.
103 static CClass *c = new CClass();
104 static CClass::NestedClass *n = new CClass::NestedClass();
105 }
106
1fcb5155
DC
107 namespace
108 {
109 int cX = 6;
110
111 namespace F
112 {
113 int cXf = 7;
79c2c32d
DC
114
115 namespace
116 {
117 int cXfX = 8;
118 }
1fcb5155
DC
119 }
120 }
121
122 namespace C
123 {
124 int cc = 2;
125 }
126
79c2c32d
DC
127 namespace E
128 {
129 int ce = 4;
130 }
131
1fcb5155
DC
132 namespace D
133 {
134 int cd = 3;
135 int shadow = 13;
136
137 namespace E
138 {
139 int cde = 5;
140 }
141
142 void marker2 (void)
143 {
144 // NOTE: carlton/2003-04-23: I'm listing the expressions that I
145 // plan to have GDB try to print out, just to make sure that the
146 // compiler and I agree which ones should be legal! It's easy
147 // to screw up when testing the boundaries of namespace stuff.
148 c;
149 //cc;
150 C::cc;
151 cd;
79c2c32d 152 //C::D::cd;
1fcb5155
DC
153 E::cde;
154 shadow;
79c2c32d 155 //E::ce;
1fcb5155
DC
156 cX;
157 F::cXf;
79c2c32d 158 F::cXfX;
1fcb5155
DC
159 X;
160 G::Xg;
161 //cXOtherFile;
162 //XOtherFile;
79c2c32d 163 G::XgX;
1fcb5155
DC
164
165 return;
166 }
167
168 }
169}
66a55e80
DB
170
171int main ()
172{
173 using AAA::inA;
174 char c1;
175
176 using namespace BBB;
177
178 c1 = xyzq ('x');
179 c1 = AAA::xyzq ('x');
180 c1 = BBB::CCC::xyzq ('m');
181
182 inA ina;
183
184 ina.xx = 33;
185
186 int y;
187
188 y = AAA::A_xyzq (33);
189 y += B_xyzq (44);
190
191 BBB::Class cl;
192
193 c1 = cl.xyzq('e');
194
195 marker1();
196
1fcb5155 197 C::D::marker2 ();
66a55e80 198}
This page took 0.934347 seconds and 4 git commands to generate.