| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 |
|
| 3 |
namespace test0 { |
| 4 |
char* p = 0; |
| 5 |
template<class T> T g(T x = &p) { return x; } |
| 6 |
template int g<int>(int); // OK even though &p isn't an int. |
| 7 |
} |
| 8 |
|
| 9 |
// Don't impose access restrictions on explicit instantiations. |
| 10 |
namespace test1 { |
| 11 |
class A { |
| 12 |
class Private {}; |
| 13 |
public: |
| 14 |
typedef Private Public; |
| 15 |
}; |
| 16 |
|
| 17 |
template <class T> class Temp { |
| 18 |
static Temp<A::Public> make() { return Temp<A::Public>(); } |
| 19 |
}; |
| 20 |
template class Temp<A::Private>; |
| 21 |
|
| 22 |
// FIXME: this ought to be an error, but it isn't because Sema is |
| 23 |
// silently failing to create a declaration for the explicit |
| 24 |
// instantiation. |
| 25 |
template class Temp<A::Private> Temp<int>::make(); |
| 26 |
} |
| 27 |
|
| 28 |
// Don't impose access restrictions on explicit specializations, |
| 29 |
// either. This goes here because it's an extension of the rule for |
| 30 |
// explicit instantiations and doesn't have any independent support. |
| 31 |
namespace test2 { |
| 32 |
class A { |
| 33 |
class Private {}; // expected-note {{implicitly declared private here}} |
| 34 |
public: |
| 35 |
typedef Private Public; |
| 36 |
}; |
| 37 |
|
| 38 |
template <class T> class Temp { |
| 39 |
static Temp<A::Public> make(); |
| 40 |
}; |
| 41 |
template <> class Temp<A::Private> { |
| 42 |
public: |
| 43 |
Temp(int x) {} |
| 44 |
}; |
| 45 |
|
| 46 |
template <> class Temp<A::Private> Temp<int>::make() { |
| 47 |
return Temp<A::Public>(0); |
| 48 |
} |
| 49 |
|
| 50 |
template <> |
| 51 |
class Temp<char> { |
| 52 |
static Temp<A::Private> make() { // expected-error {{is a private member}} |
| 53 |
return Temp<A::Public>(0); |
| 54 |
} |
| 55 |
}; |
| 56 |
} |