| 1 |
// { dg-do compile } |
| 2 |
|
| 3 |
// Origin: Alexandre Tolmos <[email protected]> |
| 4 |
|
| 5 |
// PR c++/11876: Friend of its own class diagnostics |
| 6 |
|
| 7 |
template <typename T> |
| 8 |
class A |
| 9 |
{ |
| 10 |
friend class A<int>; |
| 11 |
friend class A<float>; |
| 12 |
protected: |
| 13 |
T _data; |
| 14 |
inline A() : _data(0) {} |
| 15 |
template <typename U> |
| 16 |
inline A(const A<U>& r) : _data(r._data) {} |
| 17 |
}; |
| 18 |
|
| 19 |
class B : public A<int> |
| 20 |
{ |
| 21 |
public: |
| 22 |
inline B() {} |
| 23 |
inline B(const B& r) : A<int>(r) {} |
| 24 |
}; |
| 25 |
|
| 26 |
class C : public A<float> |
| 27 |
{ |
| 28 |
public: |
| 29 |
inline C() {} |
| 30 |
inline C(const B& r) : A<float>(r) {} |
| 31 |
}; |
| 32 |
|
| 33 |
int main(int, char*[]) |
| 34 |
{ |
| 35 |
B b1, b2(b1); |
| 36 |
C c(b1); |
| 37 |
return 0; |
| 38 |
} |