Douglas Gregor | 05030bb | 2010-03-24 01:33:17 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | |
| 3 | // PR6619 |
| 4 | template<bool C> struct if_c { }; |
| 5 | template<typename T1> struct if_ { |
Douglas Gregor | e6ec5c4 | 2010-04-28 07:04:26 +0000 | [diff] [blame] | 6 | typedef if_c< static_cast<bool>(T1::value)> almost_type_; // expected-note 5{{in instantiation}} |
Douglas Gregor | 05030bb | 2010-03-24 01:33:17 +0000 | [diff] [blame] | 7 | }; |
| 8 | template <class Model, void (Model::*)()> struct wrap_constraints { }; |
| 9 | template <class Model> |
Douglas Gregor | e6ec5c4 | 2010-04-28 07:04:26 +0000 | [diff] [blame] | 10 | inline char has_constraints_(Model* , // expected-note 2{{while substituting deduced template arguments into function template 'has_constraints_' [with }} \ |
Douglas Gregor | 05030bb | 2010-03-24 01:33:17 +0000 | [diff] [blame] | 11 | // expected-note 3{{candidate template ignored}} |
Douglas Gregor | e6ec5c4 | 2010-04-28 07:04:26 +0000 | [diff] [blame] | 12 | wrap_constraints<Model,&Model::constraints>* = 0); // expected-note 2{{in instantiation}} |
Douglas Gregor | 05030bb | 2010-03-24 01:33:17 +0000 | [diff] [blame] | 13 | |
| 14 | template <class Model> struct not_satisfied { |
| 15 | static const bool value = sizeof( has_constraints_((Model*)0) == 1); // expected-error 3{{no matching function}} |
| 16 | }; |
| 17 | template <class ModelFn> struct requirement_; |
| 18 | template <void(*)()> struct instantiate { |
| 19 | }; |
Douglas Gregor | e6ec5c4 | 2010-04-28 07:04:26 +0000 | [diff] [blame] | 20 | template <class Model> struct requirement_<void(*)(Model)> : if_< not_satisfied<Model> >::type { // expected-note 5{{in instantiation}} |
Douglas Gregor | 05030bb | 2010-03-24 01:33:17 +0000 | [diff] [blame] | 21 | }; |
| 22 | template <class Model> struct usage_requirements { |
| 23 | }; |
| 24 | template < typename TT > struct InputIterator { |
Douglas Gregor | e6ec5c4 | 2010-04-28 07:04:26 +0000 | [diff] [blame] | 25 | typedef instantiate< & requirement_<void(*)(usage_requirements<InputIterator> x)>::failed> boost_concept_check1; // expected-note {{in instantiation}} |
Douglas Gregor | 05030bb | 2010-03-24 01:33:17 +0000 | [diff] [blame] | 26 | }; |
Douglas Gregor | e6ec5c4 | 2010-04-28 07:04:26 +0000 | [diff] [blame] | 27 | template < typename TT > struct ForwardIterator : InputIterator<TT> { // expected-note {{in instantiation}} |
| 28 | typedef instantiate< & requirement_<void(*)(usage_requirements<ForwardIterator> x)>::failed> boost_concept_check2; // expected-note {{in instantiation}} |
Douglas Gregor | 05030bb | 2010-03-24 01:33:17 +0000 | [diff] [blame] | 29 | |
| 30 | }; |
Douglas Gregor | e6ec5c4 | 2010-04-28 07:04:26 +0000 | [diff] [blame] | 31 | typedef instantiate< &requirement_<void(*)(ForwardIterator<char*> x)>::failed> boost_concept_checkX;// expected-note 3{{in instantiation}} |
Douglas Gregor | 2b0749a4 | 2010-03-25 15:38:42 +0000 | [diff] [blame] | 32 | |
| 33 | template<typename T> struct X0 { }; |
| 34 | template<typename R, typename A1> struct X0<R(A1 param)> { }; |
| 35 | |
| 36 | template<typename T, typename A1, typename A2> |
| 37 | void instF0(X0<T(A1)> x0a, X0<T(A2)> x0b) { |
| 38 | X0<T(A1)> x0c; |
| 39 | X0<T(A2)> x0d; |
| 40 | } |
| 41 | |
| 42 | template void instF0<int, int, float>(X0<int(int)>, X0<int(float)>); |
Douglas Gregor | 479be1a | 2010-03-25 15:42:11 +0000 | [diff] [blame] | 43 | |
| 44 | template<typename R, typename A1, R (*ptr)(A1)> struct FuncPtr { }; |
| 45 | template<typename A1, int (*ptr)(A1)> struct FuncPtr<int, A1, ptr> { }; |
| 46 | |
| 47 | template<typename R, typename A1> R unary_func(A1); |
| 48 | |
| 49 | template<typename R, typename A1, typename A2> |
| 50 | void use_func_ptr() { |
| 51 | FuncPtr<R, A1, &unary_func<R, A1> > fp1; |
| 52 | FuncPtr<R, A2, &unary_func<R, A2> > fp2; |
| 53 | }; |
| 54 | |
| 55 | template void use_func_ptr<int, float, double>(); |