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     };
28 
29     void foo(); // expected-note {{local declaration nearly matches}}
30     struct S2 {
31       friend void foo(); // expected-note{{'::test2::foo' declared here}}
32       // TODO: the above note should go on line 24
33     };
34 
35     {
36       struct S2 {
37         friend void foo(); // expected-error {{no matching function found in local scope}}
38       };
39     }
40 
41     {
42       int foo;
43       struct S3 {
44         friend void foo(); // expected-error {{no matching function 'foo' found in local scope; did you mean '::test2::foo'?}}
45       };
46     }
47 
48     struct S4 {
49       friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}}
50       // expected-note@-1 {{'::test2::bar' declared here}}
51       // TODO: the above note should go on line 22
52     };
53 
54     { void bar(); }
55     struct S5 {
56       friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}}
57     };
58 
59     {
60       void bar();
61       struct S6 {
62         friend void bar();
63       };
64     }
65 
66     struct S7 {
67       void bar() { Inner::f(); }
68       struct Inner {
69         friend void bar();
70         static void f() {}
71       };
72     };
73 
74     void bar(); // expected-note {{'bar' declared here}}
75     struct S8 {
76       struct Inner {
77         friend void bar();
78       };
79     };
80 
81     struct S9 {
82       struct Inner {
83         friend void baz(); // expected-error {{no matching function 'baz' found in local scope; did you mean 'bar'?}}
84         // expected-note@-1 {{'::test2::bar' declared here}}
85         // TODO: the above note should go on line 22
86       };
87     };
88 
89     struct S10 {
90       void quux() {}
91       void foo() {
92         struct Inner1 {
93           friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}}
94           friend void quux(); // expected-error {{no matching function found in local scope}}
95         };
96 
97         void bar();
98         struct Inner2 {
99           friend void bar();
100         };
101       }
102     };
103   }
104 }
105