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