summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/debug/namespace1.C
blob: 6629efb9a850dc8c2ba2f50b75e1d4418a10fde8 (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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
/* Test DWARF namespace support. 
   This test case is based on GDB testsuite test case.  */
/* { dg-do compile } */

namespace AAA {
  char c;
  int i;
  int A_xyzq (int);
  char xyzq (char);
  class inA {
  public:
    int xx;
    int fum (int);
  };
};

int AAA::inA::fum (int i)
{
  return 10 + i;
}

namespace BBB {
  char c;
  int i;
  int B_xyzq (int);
  char xyzq (char);

  namespace CCC {
    char xyzq (char);
  };

  class Klasse {
  public:
    char xyzq (char);
    int dummy;
  };
};

int AAA::A_xyzq (int x)
{
  return 2 * x;
}

char AAA::xyzq (char c)
{
  return 'a';
}


int BBB::B_xyzq (int x)
{
  return 3 * x;
}

char BBB::xyzq (char c)
{
  return 'b';
}

char BBB::CCC::xyzq (char c)
{
  return 'z';
}

char BBB::Klasse::xyzq (char c)
{
  return 'o';
}

void marker1(void)
{
  return;
}

namespace
{
  int X = 9;

  namespace G
  {
    int Xg = 10;

    namespace
    {
      int XgX = 11;
    }
  }
}

namespace H
{
  int h = 14;
}

namespace I = H;

namespace J
{
  int j = 15;
}

using namespace J;

namespace K
{
  int k = 16;
}

namespace L
{
  using namespace K;
}

namespace O
{
  int o = 18;
}

namespace P
{
  using namespace O;
}

namespace Q
{
  using namespace P;
}

namespace R
{
  int r1 = 19;
  int r2 = 20;
}

using R::r1;

namespace C
{
  int c = 1;
  int shadow = 12;

  class CClass {
  public:
    int x;
    class NestedClass {
    public:
      int y;
    };
  };

  namespace
  {
    int cX = 6;
    
    namespace F
    {
      int cXf = 7;

      namespace
      {
	int cXfX = 8;
      }
    }
  }

  namespace C
  {
    int cc = 2;
  }

  namespace E
  {
    int ce = 4;
  }

  namespace D
  {
    int cd = 3;
    int shadow = 13;

    namespace E
    {
      int cde = 5;
    }

    namespace M
    {
      int cdm = 17;
    }

    using namespace M;

    void marker2 (void)
    {
      // NOTE: carlton/2003-04-23: I'm listing the expressions that I
      // plan to have GDB try to print out, just to make sure that the
      // compiler and I agree which ones should be legal!  It's easy
      // to screw up when testing the boundaries of namespace stuff.
      c;
      //cc;
      C::cc;
      cd;
      //C::D::cd;
      E::cde;
      shadow;
      //E::ce;
      cX;
      F::cXf;
      F::cXfX;
      X;
      G::Xg;
      //cXOtherFile;
      //XOtherFile;
      G::XgX;
      I::h;
      j;
      L::k;
      //k;
      cdm;
      Q::o;
      //o;
      r1;
      //r2;

      return;
    }

  }
}

int main ()
{
  using AAA::inA;
  char c1;

  using namespace BBB;
  
  c1 = xyzq ('x');
  c1 = AAA::xyzq ('x');
  c1 = BBB::CCC::xyzq ('m');
  
  inA ina;

  ina.xx = 33;

  int y;

  y = AAA::A_xyzq (33);
  y += B_xyzq (44);

  BBB::Klasse cl;

  c1 = cl.xyzq('e');

  marker1();
  
  C::D::marker2 ();
}