xref: /minix3/external/bsd/llvm/dist/clang/test/CXX/class.access/class.friend/p6.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc void f1();
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc struct X {
6*f4a2713aSLionel Sambuc   void f2();
7*f4a2713aSLionel Sambuc };
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc struct Y {
f1()10*f4a2713aSLionel Sambuc   friend void ::f1() { } // expected-error{{friend function definition cannot be qualified with '::'}}
f2Y11*f4a2713aSLionel Sambuc   friend void X::f2() { } // expected-error{{friend function definition cannot be qualified with 'X::'}}
12*f4a2713aSLionel Sambuc };
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc template <typename T> struct Z {
fZ15*f4a2713aSLionel Sambuc   friend void T::f() {} // expected-error{{friend function definition cannot be qualified with 'T::'}}
16*f4a2713aSLionel Sambuc };
17*f4a2713aSLionel Sambuc 
local()18*f4a2713aSLionel Sambuc void local() {
19*f4a2713aSLionel Sambuc   void f();
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc   struct Local {
22*f4a2713aSLionel Sambuc     friend void f() { } // expected-error{{friend function cannot be defined in a local class}}
23*f4a2713aSLionel Sambuc   };
24*f4a2713aSLionel Sambuc }
25