summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.old-deja/g++.ns/alias6.C
blob: 31b10bf38f904ff613b93426fa935c44fe115bb5 (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
// { dg-do run  }
// Check namespace aliases inside blocks
namespace A { 
  int i;
  void f(){
    i = 0;
  }
}

int g();

int main ()
{
  namespace B = A;
  B::i=42;
  B::f();
  using namespace B;
  f();
  // A::i is now 0, B::i is 1
  return g();
}

namespace B {
  int i = 1;
}

int g()
{
  namespace x = A;
  if (x::i)
  {
    namespace x = B;
    return x::i;
  }
  return x::i;
}