xref: /minix3/external/bsd/llvm/dist/clang/test/SemaTemplate/friend.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s
2*f4a2713aSLionel Sambuc template<typename T> struct A {
3*f4a2713aSLionel Sambuc   struct B { };
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc   friend struct B;
6*f4a2713aSLionel Sambuc };
7*f4a2713aSLionel Sambuc 
f()8*f4a2713aSLionel Sambuc void f() {
9*f4a2713aSLionel Sambuc   A<int>::B b;
10*f4a2713aSLionel Sambuc }
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc struct C0 {
13*f4a2713aSLionel Sambuc   friend struct A<int>;
14*f4a2713aSLionel Sambuc };
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc namespace PR6770 {
17*f4a2713aSLionel Sambuc   namespace N {
18*f4a2713aSLionel Sambuc     int f1(int);
19*f4a2713aSLionel Sambuc   }
20*f4a2713aSLionel Sambuc   using namespace N;
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc   namespace M {
23*f4a2713aSLionel Sambuc     float f1(float);
24*f4a2713aSLionel Sambuc   }
25*f4a2713aSLionel Sambuc   using M::f1;
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc   template<typename T> void f1(T, T);
28*f4a2713aSLionel Sambuc   template <class T>
f()29*f4a2713aSLionel Sambuc   void f() {
30*f4a2713aSLionel Sambuc     friend class f; // expected-error{{'friend' used outside of class}}
31*f4a2713aSLionel Sambuc     friend class f1; // expected-error{{'friend' used outside of class}}
32*f4a2713aSLionel Sambuc   }
33*f4a2713aSLionel Sambuc }
34