blob: c5b11eb5a33854b3eebde11c1ae8eb65c4f88350 (
about) (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
friend class A; // expected-error {{'friend' used outside of class}}
void f() { friend class A; } // expected-error {{'friend' used outside of class}}
class C { friend class A; };
class D { void f() { friend class A; } }; // expected-error {{'friend' used outside of class}}
// PR5760
namespace test0 {
namespace ns {
void f(int);
}
struct A {
friend void ns::f(int a);
};
}
// Test derived from LLVM's Registry.h
namespace test1 {
template <class T> struct Outer {
void foo(T);
struct Inner {
friend void Outer::foo(T);
};
};
void test() {
(void) Outer<int>::Inner();
}
}
// PR5476
namespace test2 {
namespace foo {
void Func(int x);
}
class Bar {
friend void ::test2::foo::Func(int x);
};
}
// PR5134
namespace test3 {
class Foo {
friend const int getInt(int inInt = 0);
};
}
namespace test4 {
class T4A {
friend class T4B;
public:
T4A(class T4B *);
protected:
T4B *mB; // error here
};
class T4B {};
}
namespace rdar8529993 {
struct A { ~A(); };
struct B : A
{
template<int> friend A::~A(); // expected-error {{destructor cannot be declared as a template}}
};
}
// PR7915
namespace test5 {
struct A;
struct A1 { friend void A(); };
struct B { friend void B(); };
}
// PR8479
namespace test6_1 {
class A {
public:
private:
friend class vectorA;
A() {}
};
class vectorA {
public:
vectorA(int i, const A& t = A()) {}
};
void f() {
vectorA v(1);
}
}
namespace test6_2 {
template<class T>
class vector {
public:
vector(int i, const T& t = T()) {}
};
class A {
public:
private:
friend class vector<A>;
A() {}
};
void f() {
vector<A> v(1);
}
}
namespace test6_3 {
template<class T>
class vector {
public:
vector(int i) {}
void f(const T& t = T()) {}
};
class A {
public:
private:
friend void vector<A>::f(const A&);
A() {}
};
void f() {
vector<A> v(1);
v.f();
}
}
namespace test7 {
extern "C" {
class X {
friend int f() { return 42; }
};
}
}
|