| 1 |
// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -verify %s |
| 2 |
|
| 3 |
// PR6619 |
| 4 |
template<bool C> struct if_c { }; |
| 5 |
template<typename T1> struct if_ { |
| 6 |
typedef if_c< static_cast<bool>(T1::value)> almost_type_; // expected-note 7{{in instantiation}} |
| 7 |
}; |
| 8 |
template <class Model, void (Model::*)()> struct wrap_constraints { }; |
| 9 |
template <class Model> |
| 10 |
inline char has_constraints_(Model* , // expected-note 3{{candidate template ignored}} |
| 11 |
wrap_constraints<Model,&Model::constraints>* = 0); |
| 12 |
template <class Model> struct not_satisfied { |
| 13 |
static const bool value = sizeof( has_constraints_((Model*)0) == 1); // expected-error 3{{no matching function}} \ |
| 14 |
// expected-note 4{{in instantiation}} |
| 15 |
}; |
| 16 |
template <class ModelFn> struct requirement_; |
| 17 |
template <void(*)()> struct instantiate { |
| 18 |
}; |
| 19 |
template <class Model> struct requirement_<void(*)(Model)> : if_< not_satisfied<Model> >::type { // expected-error 3{{no type named 'type' in}} expected-note 7{{in instantiation}} |
| 20 |
}; |
| 21 |
template <class Model> struct usage_requirements { |
| 22 |
}; |
| 23 |
template < typename TT > struct InputIterator { |
| 24 |
typedef instantiate< & requirement_<void(*)(usage_requirements<InputIterator> x)>::failed> boost_concept_check1; // expected-note 2{{in instantiation}} |
| 25 |
}; |
| 26 |
template < typename TT > struct ForwardIterator : InputIterator<TT> { // expected-note 2{{in instantiation}} |
| 27 |
typedef instantiate< & requirement_<void(*)(usage_requirements<ForwardIterator> x)>::failed> boost_concept_check2; // expected-note 2{{in instantiation}} |
| 28 |
|
| 29 |
}; |
| 30 |
typedef instantiate< &requirement_<void(*)(ForwardIterator<char*> x)>::failed> boost_concept_checkX;// expected-note 6{{in instantiation}} |
| 31 |
|
| 32 |
template<typename T> struct X0 { }; |
| 33 |
template<typename R, typename A1> struct X0<R(A1 param)> { }; |
| 34 |
|
| 35 |
template<typename T, typename A1, typename A2> |
| 36 |
void instF0(X0<T(A1)> x0a, X0<T(A2)> x0b) { |
| 37 |
X0<T(A1)> x0c; |
| 38 |
X0<T(A2)> x0d; |
| 39 |
} |
| 40 |
|
| 41 |
template void instF0<int, int, float>(X0<int(int)>, X0<int(float)>); |
| 42 |
|
| 43 |
template<typename R, typename A1, R (*ptr)(A1)> struct FuncPtr { }; |
| 44 |
template<typename A1, int (*ptr)(A1)> struct FuncPtr<int, A1, ptr> { }; |
| 45 |
|
| 46 |
template<typename R, typename A1> R unary_func(A1); |
| 47 |
|
| 48 |
template<typename R, typename A1, typename A2> |
| 49 |
void use_func_ptr() { |
| 50 |
FuncPtr<R, A1, &unary_func<R, A1> > fp1; |
| 51 |
FuncPtr<R, A2, &unary_func<R, A2> > fp2; |
| 52 |
}; |
| 53 |
|
| 54 |
template void use_func_ptr<int, float, double>(); |
| 55 |
|
| 56 |
namespace PR6990 { |
| 57 |
template < typename , typename = int, typename = int > struct X1; |
| 58 |
template <typename > |
| 59 |
struct X2; |
| 60 |
|
| 61 |
template <typename = int *, typename TokenT = int, |
| 62 |
typename = int( X2<TokenT> &)> |
| 63 |
struct X3 |
| 64 |
{ |
| 65 |
}; |
| 66 |
|
| 67 |
template <typename , typename P> |
| 68 |
struct X3_base : X3< X1<int, P> > |
| 69 |
{ |
| 70 |
protected: typedef X1< P> type; |
| 71 |
X3<type> e; |
| 72 |
}; |
| 73 |
|
| 74 |
struct r : X3_base<int, int> |
| 75 |
{ |
| 76 |
}; |
| 77 |
} |
| 78 |
|
| 79 |
namespace InstantiateFunctionTypedef { |
| 80 |
template<typename T> |
| 81 |
struct X { |
| 82 |
typedef int functype(int, int); |
| 83 |
functype func1; |
| 84 |
__attribute__((noreturn)) functype func2; |
| 85 |
|
| 86 |
typedef int stdfunctype(int, int) __attribute__((stdcall)); |
| 87 |
__attribute__((stdcall)) functype stdfunc1; |
| 88 |
stdfunctype stdfunc2; |
| 89 |
|
| 90 |
__attribute__((pcs("aapcs"))) functype pcsfunc; // expected-warning {{'pcs' calling convention is not supported for this target}} |
| 91 |
}; |
| 92 |
|
| 93 |
void f(X<int> x) { |
| 94 |
(void)x.func1(1, 2); |
| 95 |
(void)x.func2(1, 2); |
| 96 |
(void)x.stdfunc1(1, 2); |
| 97 |
(void)x.stdfunc2(1, 2); |
| 98 |
(void)x.pcsfunc(1, 2); |
| 99 |
} |
| 100 |
} |