2013-07-20 04:32:18 +08:00
|
|
|
// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -verify %s
|
2010-03-24 09:33:17 +08:00
|
|
|
|
|
|
|
// PR6619
|
|
|
|
template<bool C> struct if_c { };
|
|
|
|
template<typename T1> struct if_ {
|
2010-04-28 15:04:26 +08:00
|
|
|
typedef if_c< static_cast<bool>(T1::value)> almost_type_; // expected-note 5{{in instantiation}}
|
2010-03-24 09:33:17 +08:00
|
|
|
};
|
|
|
|
template <class Model, void (Model::*)()> struct wrap_constraints { };
|
|
|
|
template <class Model>
|
2014-01-11 10:37:12 +08:00
|
|
|
inline char has_constraints_(Model* , // expected-note 3{{candidate template ignored}}
|
2010-04-28 15:04:26 +08:00
|
|
|
wrap_constraints<Model,&Model::constraints>* = 0); // expected-note 2{{in instantiation}}
|
2010-03-24 09:33:17 +08:00
|
|
|
|
|
|
|
template <class Model> struct not_satisfied {
|
2014-01-11 10:37:12 +08:00
|
|
|
static const bool value = sizeof( has_constraints_((Model*)0) == 1); // expected-error 3{{no matching function}} \
|
|
|
|
// expected-note 2{{while substituting deduced template arguments into function template 'has_constraints_' [with }}
|
2010-03-24 09:33:17 +08:00
|
|
|
};
|
|
|
|
template <class ModelFn> struct requirement_;
|
|
|
|
template <void(*)()> struct instantiate {
|
|
|
|
};
|
2010-04-28 15:04:26 +08:00
|
|
|
template <class Model> struct requirement_<void(*)(Model)> : if_< not_satisfied<Model> >::type { // expected-note 5{{in instantiation}}
|
2010-03-24 09:33:17 +08:00
|
|
|
};
|
|
|
|
template <class Model> struct usage_requirements {
|
|
|
|
};
|
|
|
|
template < typename TT > struct InputIterator {
|
2010-04-28 15:04:26 +08:00
|
|
|
typedef instantiate< & requirement_<void(*)(usage_requirements<InputIterator> x)>::failed> boost_concept_check1; // expected-note {{in instantiation}}
|
2010-03-24 09:33:17 +08:00
|
|
|
};
|
2010-04-28 15:04:26 +08:00
|
|
|
template < typename TT > struct ForwardIterator : InputIterator<TT> { // expected-note {{in instantiation}}
|
|
|
|
typedef instantiate< & requirement_<void(*)(usage_requirements<ForwardIterator> x)>::failed> boost_concept_check2; // expected-note {{in instantiation}}
|
2010-03-24 09:33:17 +08:00
|
|
|
|
|
|
|
};
|
2010-04-28 15:04:26 +08:00
|
|
|
typedef instantiate< &requirement_<void(*)(ForwardIterator<char*> x)>::failed> boost_concept_checkX;// expected-note 3{{in instantiation}}
|
2010-03-25 23:38:42 +08:00
|
|
|
|
|
|
|
template<typename T> struct X0 { };
|
|
|
|
template<typename R, typename A1> struct X0<R(A1 param)> { };
|
|
|
|
|
|
|
|
template<typename T, typename A1, typename A2>
|
|
|
|
void instF0(X0<T(A1)> x0a, X0<T(A2)> x0b) {
|
|
|
|
X0<T(A1)> x0c;
|
|
|
|
X0<T(A2)> x0d;
|
|
|
|
}
|
|
|
|
|
|
|
|
template void instF0<int, int, float>(X0<int(int)>, X0<int(float)>);
|
2010-03-25 23:42:11 +08:00
|
|
|
|
|
|
|
template<typename R, typename A1, R (*ptr)(A1)> struct FuncPtr { };
|
|
|
|
template<typename A1, int (*ptr)(A1)> struct FuncPtr<int, A1, ptr> { };
|
|
|
|
|
|
|
|
template<typename R, typename A1> R unary_func(A1);
|
|
|
|
|
|
|
|
template<typename R, typename A1, typename A2>
|
|
|
|
void use_func_ptr() {
|
|
|
|
FuncPtr<R, A1, &unary_func<R, A1> > fp1;
|
|
|
|
FuncPtr<R, A2, &unary_func<R, A2> > fp2;
|
|
|
|
};
|
|
|
|
|
|
|
|
template void use_func_ptr<int, float, double>();
|
2010-05-01 02:55:50 +08:00
|
|
|
|
|
|
|
namespace PR6990 {
|
|
|
|
template < typename , typename = int, typename = int > struct X1;
|
|
|
|
template <typename >
|
|
|
|
struct X2;
|
|
|
|
|
|
|
|
template <typename = int *, typename TokenT = int,
|
|
|
|
typename = int( X2<TokenT> &)>
|
|
|
|
struct X3
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
template <typename , typename P>
|
|
|
|
struct X3_base : X3< X1<int, P> >
|
|
|
|
{
|
|
|
|
protected: typedef X1< P> type;
|
|
|
|
X3<type> e;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct r : X3_base<int, int>
|
|
|
|
{
|
|
|
|
};
|
|
|
|
}
|
2010-05-05 02:18:31 +08:00
|
|
|
|
|
|
|
namespace InstantiateFunctionTypedef {
|
|
|
|
template<typename T>
|
|
|
|
struct X {
|
|
|
|
typedef int functype(int, int);
|
2013-08-01 05:00:18 +08:00
|
|
|
functype func1;
|
|
|
|
__attribute__((noreturn)) functype func2;
|
2013-07-20 03:51:03 +08:00
|
|
|
|
|
|
|
typedef int stdfunctype(int, int) __attribute__((stdcall));
|
|
|
|
__attribute__((stdcall)) functype stdfunc1;
|
|
|
|
stdfunctype stdfunc2;
|
2013-07-20 04:32:18 +08:00
|
|
|
|
2013-08-01 05:00:18 +08:00
|
|
|
__attribute__((pcs("aapcs"))) functype pcsfunc; // expected-warning {{calling convention 'pcs' ignored for this target}}
|
2010-05-05 02:18:31 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
void f(X<int> x) {
|
2013-08-01 05:00:18 +08:00
|
|
|
(void)x.func1(1, 2);
|
|
|
|
(void)x.func2(1, 2);
|
2013-07-20 03:51:03 +08:00
|
|
|
(void)x.stdfunc1(1, 2);
|
|
|
|
(void)x.stdfunc2(1, 2);
|
2013-08-01 05:00:18 +08:00
|
|
|
(void)x.pcsfunc(1, 2);
|
2010-05-05 02:18:31 +08:00
|
|
|
}
|
|
|
|
}
|