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