1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // expected-no-diagnostics
4 // This test creates cases where implicit instantiations of various entities
5 // would cause a diagnostic, but provides expliict specializations for those
6 // entities that avoid the diagnostic. The intent is to verify that
7 // implicit instantiations do not occur (because the explicit specialization
9 struct NonDefaultConstructible
{
10 NonDefaultConstructible(int);
14 // C++ [temp.expl.spec]p1:
15 // An explicit specialization of any of the following:
17 // -- function template
18 template<typename T
> void f0(T
) {
22 template<> void f0(NonDefaultConstructible
) { }
24 void test_f0(NonDefaultConstructible NDC
) {
37 struct Inner
: public T
{ };
40 struct InnerTemplate
: public T
{ };
48 void X0
<T
>::ft1(T t
, U u
) {
52 template<typename T
> T X0
<T
>::member
;
54 template<> struct X0
<void> { };
58 // -- member function of a class template
59 template<> void X0
<void*>::f1(void *) { }
61 void test_spec(X0
<void*> xvp
, void *vp
) {
65 // -- static data member of a class template
67 NonDefaultConstructible X0
<NonDefaultConstructible
>::member
= 17;
69 NonDefaultConstructible
&get_static_member() {
70 return X0
<NonDefaultConstructible
>::member
;
73 // -- member class of a class template
75 struct X0
<void*>::Inner
{ };
77 X0
<void*>::Inner inner0
;
79 // -- member class template of a class template
82 struct X0
<void*>::InnerTemplate
<int> { };
84 X0
<void*>::InnerTemplate
<int> inner_template0
;
86 // -- member function template of a class template
89 void X0
<void*>::ft1(void*, const void*) { }
91 void test_func_template(X0
<void *> xvp
, void *vp
, const void *cvp
) {
95 // example from the standard:
96 template<class T
> class stream
;
97 template<> class stream
<char> { /* ... */ };
98 template<class T
> class Array
{ /* ... */ };
99 template<class T
> void sort(Array
<T
>& v
) { /* ... */ }
100 template<> void sort
<char*>(Array
<char*>&) ;