1 // RUN: %clang_cc1 -fsyntax-only -verify %s 2 3 namespace Ints { 4 int zero = 0; // expected-note {{candidate found by name lookup is 'Ints::zero'}} 5 void f(int); // expected-note 3 {{candidate function}} 6 void g(int); 7 } 8 9 namespace Floats { 10 float zero = 0.0f; // expected-note {{candidate found by name lookup is 'Floats::zero'}} 11 void f(float); // expected-note 3 {{candidate function}} 12 void g(float); 13 } 14 15 namespace Numbers { 16 using namespace Ints; 17 using namespace Floats; 18 } 19 20 void test() { 21 int i = Ints::zero; 22 Ints::f(i); 23 24 float f = Floats::zero; 25 Floats::f(f); 26 27 double n = Numbers::zero; // expected-error {{reference to 'zero' is ambiguous}} 28 Numbers::f(n); // expected-error{{call to 'f' is ambiguous}} 29 Numbers::f(i); 30 Numbers::f(f); 31 } 32 33 namespace Numbers { 34 struct Number { // expected-note 2 {{candidate}} 35 explicit Number(double d) : d(d) {} 36 double d; 37 }; 38 Number zero(0.0f); 39 void g(Number); // expected-note 2{{passing argument to parameter here}} 40 } 41 42 void test2() { 43 Numbers::Number n = Numbers::zero; 44 Numbers::f(n); // expected-error {{no matching function for call to 'f'}} 45 Numbers::g(n); 46 } 47 48 namespace Numbers2 { 49 using Numbers::f; 50 using Numbers::g; 51 } 52 53 void test3() { 54 Numbers::Number n = Numbers::zero; 55 Numbers2::f(n); // expected-error {{no matching function for call to 'f'}} 56 Numbers2::g(n); 57 58 int i = Ints::zero; 59 Numbers2::f(i); 60 Numbers2::g(i); // expected-error {{no viable conversion from 'int' to 'Numbers::Number'}} 61 62 float f = Floats::zero; 63 Numbers2::f(f); 64 Numbers2::g(f); // expected-error {{no viable conversion from 'float' to 'Numbers::Number'}} 65 } 66