129ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall// RUN: %clang_cc1 -fsyntax-only -verify %s 229ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall 329ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall// rdar://problem/8540720 429ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCallnamespace test0 { 529ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall void foo() { 629ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall void bar(); 729ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall class A { 829ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall friend void bar(); 929ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall }; 1029ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall } 1129ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall} 1229ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall 1329ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCallnamespace test1 { 1429ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall void foo() { 1529ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall class A { 1629ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall friend void bar(); // expected-error {{no matching function found in local scope}} 1729ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall }; 1829ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall } 1929ae6e5fb001deddd831e66faf143ecd9e50f67cJohn McCall} 204e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith 214e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smithnamespace test2 { 224e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith void bar(); // expected-note {{'::test2::bar' declared here}} 234e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith 244e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith void foo() { // expected-note {{'::test2::foo' declared here}} 254e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct S1 { 264e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith friend void foo(); // expected-error {{no matching function 'foo' found in local scope; did you mean '::test2::foo'?}} 274e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 284e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith 294e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith void foo(); // expected-note {{local declaration nearly matches}} 304e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct S2 { 31a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar friend void foo(); // expected-note{{'::test2::foo' declared here}} 32a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar // TODO: the above note should go on line 24 334e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 344e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith 354e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith { 364e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct S2 { 374e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith friend void foo(); // expected-error {{no matching function found in local scope}} 384e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 394e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith } 404e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith 414e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith { 424e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith int foo; 434e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct S3 { 440e2c34f92f00628d48968dfea096d36381f494cbStephen Hines friend void foo(); // expected-error {{no matching function 'foo' found in local scope; did you mean '::test2::foo'?}} 454e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 464e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith } 474e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith 484e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct S4 { 494e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}} 50a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar // expected-note@-1 {{'::test2::bar' declared here}} 51a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar // TODO: the above note should go on line 22 524e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 534e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith 544e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith { void bar(); } 554e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct S5 { 560e2c34f92f00628d48968dfea096d36381f494cbStephen Hines friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}} 574e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 584e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith 594e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith { 604e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith void bar(); 614e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct S6 { 624e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith friend void bar(); 634e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 644e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith } 654e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith 664e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct S7 { 674e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith void bar() { Inner::f(); } 684e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct Inner { 694e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith friend void bar(); 704e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith static void f() {} 714e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 724e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 734e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith 744e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith void bar(); // expected-note {{'bar' declared here}} 754e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct S8 { 764e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct Inner { 774e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith friend void bar(); 784e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 794e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 804e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith 814e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct S9 { 824e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct Inner { 834e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith friend void baz(); // expected-error {{no matching function 'baz' found in local scope; did you mean 'bar'?}} 84a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar // expected-note@-1 {{'::test2::bar' declared here}} 85a4de17562d13d7a8188108243c4cfbd52f33229aPirama Arumuga Nainar // TODO: the above note should go on line 22 864e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 874e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 884e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith 894e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct S10 { 904e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith void quux() {} 914e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith void foo() { 924e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct Inner1 { 930e2c34f92f00628d48968dfea096d36381f494cbStephen Hines friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}} 944e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith friend void quux(); // expected-error {{no matching function found in local scope}} 954e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 964e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith 974e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith void bar(); 984e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith struct Inner2 { 994e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith friend void bar(); 1004e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 1014e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith } 1024e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith }; 1034e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith } 1044e9686b1f9947f1747b4f4316deb2087a7f56282Richard Smith} 105