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