1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify %s 2*67e74705SXin Li 3*67e74705SXin Li // rdar://problem/8540720 4*67e74705SXin Li namespace test0 { foo()5*67e74705SXin Li void foo() { 6*67e74705SXin Li void bar(); 7*67e74705SXin Li class A { 8*67e74705SXin Li friend void bar(); 9*67e74705SXin Li }; 10*67e74705SXin Li } 11*67e74705SXin Li } 12*67e74705SXin Li 13*67e74705SXin Li namespace test1 { foo()14*67e74705SXin Li void foo() { 15*67e74705SXin Li class A { 16*67e74705SXin Li friend void bar(); // expected-error {{no matching function found in local scope}} 17*67e74705SXin Li }; 18*67e74705SXin Li } 19*67e74705SXin Li } 20*67e74705SXin Li 21*67e74705SXin Li namespace test2 { 22*67e74705SXin Li void bar(); // expected-note {{'::test2::bar' declared here}} 23*67e74705SXin Li foo()24*67e74705SXin Li void foo() { // expected-note {{'::test2::foo' declared here}} 25*67e74705SXin Li struct S1 { 26*67e74705SXin Li friend void foo(); // expected-error {{no matching function 'foo' found in local scope; did you mean '::test2::foo'?}} 27*67e74705SXin Li }; 28*67e74705SXin Li 29*67e74705SXin Li void foo(); // expected-note {{local declaration nearly matches}} 30*67e74705SXin Li struct S2 { 31*67e74705SXin Li friend void foo(); // expected-note{{'::test2::foo' declared here}} 32*67e74705SXin Li // TODO: the above note should go on line 24 33*67e74705SXin Li }; 34*67e74705SXin Li 35*67e74705SXin Li { 36*67e74705SXin Li struct S2 { 37*67e74705SXin Li friend void foo(); // expected-error {{no matching function found in local scope}} 38*67e74705SXin Li }; 39*67e74705SXin Li } 40*67e74705SXin Li 41*67e74705SXin Li { 42*67e74705SXin Li int foo; 43*67e74705SXin Li struct S3 { 44*67e74705SXin Li friend void foo(); // expected-error {{no matching function 'foo' found in local scope; did you mean '::test2::foo'?}} 45*67e74705SXin Li }; 46*67e74705SXin Li } 47*67e74705SXin Li 48*67e74705SXin Li struct S4 { 49*67e74705SXin Li friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}} 50*67e74705SXin Li // expected-note@-1 {{'::test2::bar' declared here}} 51*67e74705SXin Li // TODO: the above note should go on line 22 52*67e74705SXin Li }; 53*67e74705SXin Li 54*67e74705SXin Li { void bar(); } 55*67e74705SXin Li struct S5 { 56*67e74705SXin Li friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}} 57*67e74705SXin Li }; 58*67e74705SXin Li 59*67e74705SXin Li { 60*67e74705SXin Li void bar(); 61*67e74705SXin Li struct S6 { 62*67e74705SXin Li friend void bar(); 63*67e74705SXin Li }; 64*67e74705SXin Li } 65*67e74705SXin Li 66*67e74705SXin Li struct S7 { 67*67e74705SXin Li void bar() { Inner::f(); } 68*67e74705SXin Li struct Inner { 69*67e74705SXin Li friend void bar(); 70*67e74705SXin Li static void f() {} 71*67e74705SXin Li }; 72*67e74705SXin Li }; 73*67e74705SXin Li 74*67e74705SXin Li void bar(); // expected-note {{'bar' declared here}} 75*67e74705SXin Li struct S8 { 76*67e74705SXin Li struct Inner { 77*67e74705SXin Li friend void bar(); 78*67e74705SXin Li }; 79*67e74705SXin Li }; 80*67e74705SXin Li 81*67e74705SXin Li struct S9 { 82*67e74705SXin Li struct Inner { 83*67e74705SXin Li friend void baz(); // expected-error {{no matching function 'baz' found in local scope; did you mean 'bar'?}} 84*67e74705SXin Li // expected-note@-1 {{'::test2::bar' declared here}} 85*67e74705SXin Li // TODO: the above note should go on line 22 86*67e74705SXin Li }; 87*67e74705SXin Li }; 88*67e74705SXin Li 89*67e74705SXin Li struct S10 { 90*67e74705SXin Li void quux() {} 91*67e74705SXin Li void foo() { 92*67e74705SXin Li struct Inner1 { 93*67e74705SXin Li friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}} 94*67e74705SXin Li friend void quux(); // expected-error {{no matching function found in local scope}} 95*67e74705SXin Li }; 96*67e74705SXin Li 97*67e74705SXin Li void bar(); 98*67e74705SXin Li struct Inner2 { 99*67e74705SXin Li friend void bar(); 100*67e74705SXin Li }; 101*67e74705SXin Li } 102*67e74705SXin Li }; 103*67e74705SXin Li } 104*67e74705SXin Li } 105