brintos

brintos / llvm-project-archived public Read only

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