2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2009-03-28 14:23:46 +08:00
|
|
|
|
|
|
|
namespace N { };
|
|
|
|
|
|
|
|
namespace A = N;
|
|
|
|
|
|
|
|
int B; // expected-note {{previous definition is here}}
|
|
|
|
namespace B = N; // expected-error {{redefinition of 'B' as different kind of symbol}}
|
|
|
|
|
|
|
|
namespace C { } // expected-note {{previous definition is here}}
|
|
|
|
namespace C = N; // expected-error {{redefinition of 'C'}}
|
2009-03-28 14:42:02 +08:00
|
|
|
|
|
|
|
int i;
|
|
|
|
namespace D = i; // expected-error {{expected namespace name}}
|
|
|
|
|
|
|
|
namespace E = N::Foo; // expected-error {{expected namespace name}}
|
2009-03-28 15:51:31 +08:00
|
|
|
|
|
|
|
namespace F {
|
|
|
|
namespace A { namespace B { } } // expected-note {{candidate found by name lookup is 'F::A::B'}}
|
|
|
|
namespace B { } // expected-note {{candidate found by name lookup is 'F::B'}}
|
|
|
|
using namespace A;
|
|
|
|
namespace D = B; // expected-error {{reference to 'B' is ambiguous}}
|
|
|
|
}
|
2009-03-29 07:49:35 +08:00
|
|
|
|
|
|
|
namespace G {
|
|
|
|
namespace B = N;
|
|
|
|
}
|
2009-03-29 07:53:49 +08:00
|
|
|
|
|
|
|
namespace H {
|
|
|
|
namespace A1 { }
|
|
|
|
namespace A2 { }
|
|
|
|
|
|
|
|
// These all point to A1.
|
|
|
|
namespace B = A1; // expected-note {{previous definition is here}}
|
|
|
|
namespace B = A1;
|
|
|
|
namespace C = B;
|
|
|
|
namespace B = C;
|
|
|
|
|
|
|
|
namespace B = A2; // expected-error {{redefinition of 'B' as different kind of symbol}}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace I {
|
|
|
|
namespace A1 { int i; }
|
|
|
|
|
|
|
|
namespace A2 = A1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int f() {
|
|
|
|
return I::A2::i;
|
|
|
|
}
|
2009-03-31 13:47:19 +08:00
|
|
|
|
|
|
|
namespace J {
|
|
|
|
namespace A {
|
|
|
|
namespace B { void func (); }
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace C = A;
|
|
|
|
|
|
|
|
using namespace C::B;
|
|
|
|
|
|
|
|
void g() {
|
|
|
|
func();
|
|
|
|
}
|
|
|
|
}
|
2010-02-16 14:53:13 +08:00
|
|
|
|
|
|
|
namespace K {
|
|
|
|
namespace KA { void func(); }
|
|
|
|
|
|
|
|
void f() {
|
|
|
|
namespace KB = KA;
|
|
|
|
KB::func();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T> void g() {
|
|
|
|
namespace KC = KA;
|
|
|
|
KC::func();
|
|
|
|
}
|
|
|
|
template void g<int>();
|
|
|
|
template void g<long>();
|
|
|
|
|
|
|
|
void h() {
|
|
|
|
KB::func(); // expected-error {{undeclared identifier 'KB'}}
|
|
|
|
KC::func(); // expected-error {{undeclared identifier 'KC'}}
|
|
|
|
}
|
|
|
|
}
|