Home | History | Annotate | Download | only in class.friend
      1 // RUN: %clang_cc1 -fsyntax-only -verify %s
      2 
      3 // rdar://problem/8540720
      4 namespace test0 {
      5   void foo() {
      6     void bar();
      7     class A {
      8       friend void bar();
      9     };
     10   }
     11 }
     12 
     13 namespace test1 {
     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 
     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();
     32     };
     33 
     34     {
     35       struct S2 {
     36         friend void foo(); // expected-error {{no matching function found in local scope}}
     37       };
     38     }
     39 
     40     {
     41       int foo;
     42       struct S3 {
     43         friend void foo(); // expected-error {{no matching function found in local scope}}
     44       };
     45     }
     46 
     47     struct S4 {
     48       friend void bar(); // expected-error {{no matching function 'bar' found in local scope; did you mean '::test2::bar'?}}
     49     };
     50 
     51     { void bar(); }
     52     struct S5 {
     53       friend void bar(); // expected-error {{no matching function found in local scope}}
     54     };
     55 
     56     {
     57       void bar();
     58       struct S6 {
     59         friend void bar();
     60       };
     61     }
     62 
     63     struct S7 {
     64       void bar() { Inner::f(); }
     65       struct Inner {
     66         friend void bar();
     67         static void f() {}
     68       };
     69     };
     70 
     71     void bar(); // expected-note {{'bar' declared here}}
     72     struct S8 {
     73       struct Inner {
     74         friend void bar();
     75       };
     76     };
     77 
     78     struct S9 {
     79       struct Inner {
     80         friend void baz(); // expected-error {{no matching function 'baz' found in local scope; did you mean 'bar'?}}
     81       };
     82     };
     83 
     84     struct S10 {
     85       void quux() {}
     86       void foo() {
     87         struct Inner1 {
     88           friend void bar(); // expected-error {{no matching function found in local scope}}
     89           friend void quux(); // expected-error {{no matching function found in local scope}}
     90         };
     91 
     92         void bar();
     93         struct Inner2 {
     94           friend void bar();
     95         };
     96       }
     97     };
     98   }
     99 }
    100