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 test()20void 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}} NumberNumbers::Number35 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 test2()42void 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 test3()53void 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 67 namespace inline_ns { 68 int x; // expected-note 2{{found}} 69 inline namespace A { // expected-warning {{C++11}} 70 int x; // expected-note 2{{found}} 71 int y; // expected-note 2{{found}} 72 } 73 int y; // expected-note 2{{found}} 74 int k1 = x + y; // expected-error 2{{ambiguous}} 75 int k2 = inline_ns::x + inline_ns::y; // expected-error 2{{ambiguous}} 76 } 77