xref: /minix3/external/bsd/llvm/dist/clang/test/Parser/cxx-using-directive.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc class A {};
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc namespace B {
6*f4a2713aSLionel Sambuc   namespace A {} // expected-note{{namespace '::B::A' defined here}} \
7*f4a2713aSLionel Sambuc                  // expected-note 2{{namespace 'B::A' defined here}}
8*f4a2713aSLionel Sambuc   using namespace A ;
9*f4a2713aSLionel Sambuc }
10*f4a2713aSLionel Sambuc 
11*f4a2713aSLionel Sambuc namespace C {} // expected-note{{namespace 'C' defined here}}
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc namespace D {
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc   class C {
16*f4a2713aSLionel Sambuc 
17*f4a2713aSLionel Sambuc     using namespace B ; // expected-error{{not allowed}}
18*f4a2713aSLionel Sambuc   };
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc   namespace B {}
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc   using namespace C ;
23*f4a2713aSLionel Sambuc   using namespace B::A ; // expected-error{{no namespace named 'A' in namespace 'D::B'; did you mean '::B::A'?}}
24*f4a2713aSLionel Sambuc   using namespace ::B::A ;
25*f4a2713aSLionel Sambuc   using namespace ::D::F ; // expected-error{{expected namespace name}}
26*f4a2713aSLionel Sambuc   using namespace ::D::C ; // expected-error{{no namespace named 'C' in namespace 'D'; did you mean simply 'C'?}}
27*f4a2713aSLionel Sambuc }
28*f4a2713aSLionel Sambuc 
29*f4a2713aSLionel Sambuc using namespace ! ; // expected-error{{expected namespace name}}
30*f4a2713aSLionel Sambuc using namespace A ; // expected-error{{no namespace named 'A'; did you mean 'B::A'?}}
31*f4a2713aSLionel Sambuc using namespace ::A // expected-error{{no namespace named 'A' in the global namespace; did you mean 'B::A'?}} \
32*f4a2713aSLionel Sambuc                     // expected-error{{expected ';' after namespace name}}
33*f4a2713aSLionel Sambuc                     B ;
34*f4a2713aSLionel Sambuc 
test_nslookup()35*f4a2713aSLionel Sambuc void test_nslookup() {
36*f4a2713aSLionel Sambuc   int B;
37*f4a2713aSLionel Sambuc   class C;
38*f4a2713aSLionel Sambuc   using namespace B;
39*f4a2713aSLionel Sambuc   using namespace C;
40*f4a2713aSLionel Sambuc }
41