1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
6 template <class T
> struct X
{};
8 template <> struct X
<char>
13 template <class T
> struct X2
{};
22 void a(char *a
, char *b
) {X2
<char*>::f();}
24 namespace WonkyAccess
{
34 struct Y
<U
*> : X
<U
> { };
37 struct Y
<float*> : X
<float> { };
39 int f(Y
<int*> y
, Y
<float*> y2
) {
44 // <rdar://problem/9169404>
45 namespace rdar9169404
{
46 template<typename T
, T N
> struct X
{ };
47 template<bool C
> struct X
<bool, C
> {
51 X
<bool, -1>::type value
;
52 #if __cplusplus >= 201103L
53 // expected-error@-2 {{non-type template argument evaluates to -1, which cannot be narrowed to type 'bool'}}
57 // rdar://problem/39524996
58 namespace rdar39524996
{
59 template <typename T
, typename U
>
60 struct enable_if_not_same
65 struct enable_if_not_same
<T
, T
>;
69 // Assertion triggered on trying to set twice the same partial specialization
70 // enable_if_not_same<int, int>
72 Wrapper(const Wrapper
<U
>& other
,
73 typename enable_if_not_same
<U
, T
>::type
* = 0) {}
75 explicit Wrapper(int i
) {}
80 // It is important that the struct has implicit copy and move constructors.
84 Container(const Container
<U
>& other
) : x(static_cast<T
>(other
.x
)) {}
86 // Implicit constructors are member-wise, so the field triggers instantiation
87 // of T constructors and we instantiate all of them for overloading purposes.
91 void takesWrapperInContainer(const Container
< Wrapper
<int> >& c
);
93 // Type mismatch triggers initialization with conversion which requires
94 // implicit constructors to be instantiated.
96 takesWrapperInContainer(c
);
100 namespace InstantiationDependent
{
101 template<typename
> using ignore
= void; // expected-warning 0-1{{extension}}
102 template<typename T
, typename
= void> struct A
{
103 static const bool specialized
= false;
105 template<typename T
> struct Hide
{ typedef void type
; };
106 template<typename T
> struct A
<T
, Hide
<ignore
<typename
T::type
> >::type
> {
107 static const bool specialized
= true;
111 struct Y
{ typedef int type
; };
112 _Static_assert(!A
<X
>::specialized
, "");
113 _Static_assert(A
<Y
>::specialized
, "");
116 namespace IgnorePartialSubstitution
{
117 template <typename
... T
> struct tuple
{}; // expected-warning 0-1{{extension}}
118 template <typename
> struct IsTuple
{
119 enum { value
= false };
121 template <typename
... Us
> struct IsTuple
<tuple
<Us
...> > { // expected-warning 0-1{{extension}}
122 enum { value
= true };
125 template <bool...> using ignore
= void; // expected-warning 0-2{{extension}}
126 template <class... Pred
> ignore
<Pred::value
...> helper(); // expected-warning 0-1{{extension}}
128 using S
= IsTuple
<tuple
<int> >; // expected-warning 0-1{{extension}}
130 // This used to pick the primary template, because we got confused and
131 // thought that template parameter 0 was the current partially-substituted
132 // pack (from `helper`) during the deduction for the partial specialization.
133 void f() { helper
<S
>(); }
135 _Static_assert(S::value
, "");