1 // RUN: %clang_cc1 -fsyntax-only -verify %s
4 class X
{ }; // expected-note{{candidate found by name lookup is 'A::X'}}
5 // expected-note@-1{{candidate found by name lookup is 'A::X'}}
8 void X(int); // expected-note{{candidate found by name lookup is 'B::X'}}
9 // expected-note@-1{{candidate found by name lookup is 'B::X'}}
12 // Using directive doesn't cause A::X to be hidden, so X is ambiguous.
18 X(1); // expected-error{{reference to 'X' is ambiguous}}
27 X(1); // expected-error{{reference to 'X' is ambiguous}}
31 // The behaviour here should be the same as using namespaces A and B directly
34 using A::X
; // expected-note{{candidate found by name lookup is 'Test2a::C::X'}}
37 using B::X
; // expected-note{{candidate found by name lookup is 'Test2a::D::X'}}
43 X(1); // expected-error{{reference to 'X' is ambiguous}}
49 using A::X
; // expected-note{{candidate found by name lookup is 'Test2b::C::X'}}
52 using B::X
; // expected-note{{candidate found by name lookup is 'Test2b::D::X'}}
58 X(1); // expected-error{{reference to 'X' is ambiguous}}
62 // Defining a function X inside C should hide using A::X in C but not D, so the result is ambiguous.
66 void X(int); // expected-note{{candidate found by name lookup is 'Test3a::C::X'}}
69 using A::X
; // expected-note{{candidate found by name lookup is 'Test3a::D::X'}}
74 X(1); // expected-error{{reference to 'X' is ambiguous}}
81 void X(int); // expected-note{{candidate found by name lookup is 'Test3b::C::X'}}
84 using A::X
; // expected-note{{candidate found by name lookup is 'Test3b::D::X'}}
89 X(1); // expected-error{{reference to 'X' is ambiguous}}
95 void X(int); // expected-note{{candidate found by name lookup is 'Test3c::C::X'}}
99 using A::X
; // expected-note{{candidate found by name lookup is 'Test3c::D::X'}}
104 X(1); // expected-error{{reference to 'X' is ambiguous}}
110 void X(int); // expected-note{{candidate found by name lookup is 'Test3d::C::X'}}
114 using A::X
; // expected-note{{candidate found by name lookup is 'Test3d::D::X'}}
119 X(1); // expected-error{{reference to 'X' is ambiguous}}
123 // A::X hidden in both C and D by overloaded function, so the result is not ambiguous.
188 // B::X hides class X in C, so the the result is not ambiguous
249 // B::X hides class X declared in both C and D, so the result is not ambiguous.
314 // function X inside C should hide class X in C but not D.
318 void X(int); // expected-note{{candidate found by name lookup is 'Test7a::C::X'}}
321 class X
; // expected-note{{candidate found by name lookup is 'Test7a::D::X'}}
326 X(1); // expected-error{{reference to 'X' is ambiguous}}
333 void X(int); // expected-note{{candidate found by name lookup is 'Test7b::C::X'}}
336 class X
; // expected-note{{candidate found by name lookup is 'Test7b::D::X'}}
341 X(1); // expected-error{{reference to 'X' is ambiguous}}
347 void X(int); // expected-note{{candidate found by name lookup is 'Test7c::C::X'}}
351 class X
; // expected-note{{candidate found by name lookup is 'Test7c::D::X'}}
356 X(1); // expected-error{{reference to 'X' is ambiguous}}
362 void X(int); // expected-note{{candidate found by name lookup is 'Test7d::C::X'}}
366 class X
; // expected-note{{candidate found by name lookup is 'Test7d::D::X'}}
371 X(1); // expected-error{{reference to 'X' is ambiguous}}