using-directive.cpp revision caf2bc13de5e81f4b3335bd02a45e42ea01fc1aa
1// RUN: clang-cc -fsyntax-only -verify %s 2// XFAIL 3 4namespace A { 5 short i; // expected-note 2{{candidate found by name lookup is 'A::i'}} 6 namespace B { 7 long i; // expected-note{{candidate found by name lookup is 'A::B::i'}} 8 void f() {} // expected-note{{candidate function}} 9 int k; 10 namespace E {} // \ 11 expected-note{{candidate found by name lookup is 'A::B::E'}} 12 } 13 14 namespace E {} // expected-note{{candidate found by name lookup is 'A::E'}} 15 16 namespace C { 17 using namespace B; 18 namespace E {} // \ 19 expected-note{{candidate found by name lookup is 'A::C::E'}} 20 } 21 22 void f() {} // expected-note{{candidate function}} 23 24 class K1 { 25 void foo(); 26 }; 27 28 void local_i() { 29 char i; 30 using namespace A; 31 using namespace B; 32 int a[sizeof(i) == sizeof(char)? 1 : -1]; // okay 33 } 34 namespace B { 35 int j; 36 } 37 38 void ambig_i() { 39 using namespace A; 40 using namespace A::B; 41 (void) i; // expected-error{{reference to 'i' is ambiguous}} 42 f(); // expected-error{{call to 'f' is ambiguous}} 43 (void) j; // okay 44 using namespace C; 45 (void) k; // okay 46 using namespace E; // expected-error{{reference to 'E' is ambiguous}} 47 } 48 49 struct K2 {}; // expected-note{{candidate found by name lookup is 'A::K2'}} 50} 51 52struct K2 {}; // expected-note{{candidate found by name lookup is 'K2'}} 53 54using namespace A; 55 56void K1::foo() {} // okay 57 58// FIXME: Do we want err_ovl_no_viable_function_in_init here? 59struct K2 k2; // expected-error{{reference to 'K2' is ambiguous}} \ 60 expected-error{{incomplete type}} 61 62// FIXME: This case is incorrectly diagnosed! 63//K2 k3; 64 65 66class X { // expected-note{{candidate found by name lookup is 'X'}} 67 // FIXME: produce a suitable error message for this 68 using namespace A; // expected-error{{expected member name or}} 69}; 70 71namespace N { 72 struct K2; 73 struct K2 { }; 74} 75 76namespace Ni { 77 int i(); // expected-note{{candidate found by name lookup is 'Ni::i'}} 78} 79 80namespace NiTest { 81 using namespace A; 82 using namespace Ni; 83 84 int test() { 85 return i; // expected-error{{reference to 'i' is ambiguous}} 86 } 87} 88 89namespace OneTag { 90 struct X; // expected-note{{candidate found by name lookup is 'OneTag::X'}} 91} 92 93namespace OneFunction { 94 void X(); // expected-note{{candidate found by name lookup is 'OneFunction::X'}} 95} 96 97namespace TwoTag { 98 struct X; // expected-note{{candidate found by name lookup is 'TwoTag::X'}} \ 99 // expected-note{{forward declaration}} 100} 101 102namespace FuncHidesTagAmbiguity { 103 using namespace OneTag; 104 using namespace OneFunction; 105 using namespace TwoTag; 106 107 void test() { 108 (void)X(); // expected-error{{reference to 'X' is ambiguous}} \ 109 // FIXME: expected-error{{invalid use of incomplete type}} 110 } 111} 112