xref: /llvm-project/clang/test/CXX/class.access/class.friend/p6.cpp (revision 29bd78b2f61e638f6c26bc417ae476754b91e985)
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 
3 void f1();
4 
5 struct X {
6   void f2();
7 };
8 
9 struct Y {
f1()10   friend void ::f1() { } // expected-error{{friend function definition cannot be qualified with '::'}}
f2Y11   friend void X::f2() { } // expected-error{{friend function definition cannot be qualified with 'X::'}}
12 };
13 
14 template <typename T> struct Z {
fZ15   friend void T::f() {} // expected-error{{friend function definition cannot be qualified with 'T::'}}
16 };
17 
local()18 void local() {
19   void f();
20 
21   struct Local {
22     friend void f() { } // expected-error{{friend function cannot be defined in a local class}}
23   };
24 }
25 
26 template<typename T> void f3(T);
27 
28 namespace N {
29   template<typename T> void f4(T);
30 }
31 
32 template<typename T> struct A {
f3(T)33   friend void f3(T) {}
34   friend void f3<T>(T) {} // expected-error{{friend function specialization cannot be defined}}
f4A35   friend void N::f4(T) {} // expected-error{{friend function definition cannot be qualified with 'N::'}}
36   friend void N::f4<T>(T) {} // expected-error{{friend function definition cannot be qualified with 'N::'}}
37 };
38