blob: 84a8e899dbeab5252338d1ec58b53f4f362cf4fa [file] [log] [blame]
Douglas Gregor182ddf02009-09-28 00:08:27 +00001// RUN: clang-cc -fsyntax-only -verify %s
Douglas Gregord85bea22009-09-26 06:47:28 +00002
3// PR5057
4namespace std {
5 class X {
6 public:
7 template<typename T>
8 friend struct Y;
9 };
10}
11
12namespace std {
13 template<typename T>
14 struct Y
15 {
16 };
17}
Douglas Gregor182ddf02009-09-28 00:08:27 +000018
19
20namespace N {
21 template<typename T> void f1(T) { } // expected-note{{here}}
22
23 class X {
24 template<typename T> friend void f0(T);
25 template<typename T> friend void f1(T);
26 };
27
28 template<typename T> void f0(T) { }
29 template<typename T> void f1(T) { } // expected-error{{redefinition}}
30}
Douglas Gregord7e5bdb2009-10-09 21:11:42 +000031
32// PR4768
33template<typename T>
34struct X0 {
35 template<typename U> friend struct X0;
36};
37
38template<typename T>
39struct X0<T*> {
40 template<typename U> friend struct X0;
41};
42
43template<>
44struct X0<int> {
45 template<typename U> friend struct X0;
46};
Douglas Gregora735b202009-10-13 14:39:41 +000047
48template<typename T>
49struct X1 {
50 template<typename U> friend void f2(U);
51 template<typename U> friend void f3(U);
52};
53
54template<typename U> void f2(U);
55
56X1<int> x1i;
Douglas Gregore8c01bd2009-10-30 21:07:27 +000057X0<int*> x0ip;
Douglas Gregora735b202009-10-13 14:39:41 +000058
59template<> void f2(int);
60
61// FIXME: Should this declaration of f3 be required for the specialization of
62// f3<int> (further below) to work? GCC and EDG don't require it, we do...
63template<typename U> void f3(U);
64
65template<> void f3(int);
Douglas Gregore8c01bd2009-10-30 21:07:27 +000066
67// PR5332
68template <typename T>
69class Foo {
70 template <typename U>
71 friend class Foo;
72};
73
74Foo<int> foo;
Douglas Gregor259571e2009-10-30 22:42:42 +000075
76template<typename T, T Value>
77struct X2a;
78
79template<typename T, int Size>
80struct X2b;
81
82template<typename T>
83class X3 {
84 template<typename U, U Value>
85 friend struct X2a;
86
87 template<typename U, T Value>
88 friend struct X2b;
89};
90
91X3<int> x3i; // okay
92
93X3<long> x3l; // FIXME: should cause an instantiation-time failure