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