blob: 556a8181f0435e542d0509a500ba19e90c1289c7 [file] [log] [blame]
Reid Klecknerc6274ce2013-07-19 20:32:18 +00001// RUN: %clang_cc1 -triple i686-unknown-unknown -fsyntax-only -verify %s
Douglas Gregor05030bb2010-03-24 01:33:17 +00002
3// PR6619
4template<bool C> struct if_c { };
5template<typename T1> struct if_ {
Douglas Gregore6ec5c42010-04-28 07:04:26 +00006 typedef if_c< static_cast<bool>(T1::value)> almost_type_; // expected-note 5{{in instantiation}}
Douglas Gregor05030bb2010-03-24 01:33:17 +00007};
8template <class Model, void (Model::*)()> struct wrap_constraints { };
9template <class Model>
Stephen Hines651f13c2014-04-23 16:59:28 -070010inline char has_constraints_(Model* , // expected-note 3{{candidate template ignored}}
Douglas Gregore6ec5c42010-04-28 07:04:26 +000011 wrap_constraints<Model,&Model::constraints>* = 0); // expected-note 2{{in instantiation}}
Douglas Gregor05030bb2010-03-24 01:33:17 +000012
13template <class Model> struct not_satisfied {
Stephen Hines651f13c2014-04-23 16:59:28 -070014 static const bool value = sizeof( has_constraints_((Model*)0) == 1); // expected-error 3{{no matching function}} \
15 // expected-note 2{{while substituting deduced template arguments into function template 'has_constraints_' [with }}
Douglas Gregor05030bb2010-03-24 01:33:17 +000016};
17template <class ModelFn> struct requirement_;
18template <void(*)()> struct instantiate {
19};
Douglas Gregore6ec5c42010-04-28 07:04:26 +000020template <class Model> struct requirement_<void(*)(Model)> : if_< not_satisfied<Model> >::type { // expected-note 5{{in instantiation}}
Douglas Gregor05030bb2010-03-24 01:33:17 +000021};
22template <class Model> struct usage_requirements {
23};
24template < typename TT > struct InputIterator {
Douglas Gregore6ec5c42010-04-28 07:04:26 +000025 typedef instantiate< & requirement_<void(*)(usage_requirements<InputIterator> x)>::failed> boost_concept_check1; // expected-note {{in instantiation}}
Douglas Gregor05030bb2010-03-24 01:33:17 +000026};
Douglas Gregore6ec5c42010-04-28 07:04:26 +000027template < 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 Gregor05030bb2010-03-24 01:33:17 +000029
30};
Douglas Gregore6ec5c42010-04-28 07:04:26 +000031typedef instantiate< &requirement_<void(*)(ForwardIterator<char*> x)>::failed> boost_concept_checkX;// expected-note 3{{in instantiation}}
Douglas Gregor2b0749a42010-03-25 15:38:42 +000032
33template<typename T> struct X0 { };
34template<typename R, typename A1> struct X0<R(A1 param)> { };
35
36template<typename T, typename A1, typename A2>
37void instF0(X0<T(A1)> x0a, X0<T(A2)> x0b) {
38 X0<T(A1)> x0c;
39 X0<T(A2)> x0d;
40}
41
42template void instF0<int, int, float>(X0<int(int)>, X0<int(float)>);
Douglas Gregor479be1a2010-03-25 15:42:11 +000043
44template<typename R, typename A1, R (*ptr)(A1)> struct FuncPtr { };
45template<typename A1, int (*ptr)(A1)> struct FuncPtr<int, A1, ptr> { };
46
47template<typename R, typename A1> R unary_func(A1);
48
49template<typename R, typename A1, typename A2>
50void use_func_ptr() {
51 FuncPtr<R, A1, &unary_func<R, A1> > fp1;
52 FuncPtr<R, A2, &unary_func<R, A2> > fp2;
53};
54
55template void use_func_ptr<int, float, double>();
Douglas Gregor895162d2010-04-30 18:55:50 +000056
57namespace PR6990 {
58 template < typename , typename = int, typename = int > struct X1;
59 template <typename >
60 struct X2;
61
62 template <typename = int *, typename TokenT = int,
63 typename = int( X2<TokenT> &)>
64 struct X3
65 {
66 };
67
68 template <typename , typename P>
69 struct X3_base : X3< X1<int, P> >
70 {
71 protected: typedef X1< P> type;
72 X3<type> e;
73 };
74
75 struct r : X3_base<int, int>
76 {
77 };
78}
Douglas Gregor5f970ee2010-05-04 18:18:31 +000079
80namespace InstantiateFunctionTypedef {
81 template<typename T>
82 struct X {
83 typedef int functype(int, int);
Reid Klecknerc66e7e92013-07-31 21:00:18 +000084 functype func1;
85 __attribute__((noreturn)) functype func2;
Reid Kleckner5b926962013-07-19 19:51:03 +000086
87 typedef int stdfunctype(int, int) __attribute__((stdcall));
88 __attribute__((stdcall)) functype stdfunc1;
89 stdfunctype stdfunc2;
Reid Klecknerc6274ce2013-07-19 20:32:18 +000090
Reid Klecknerc66e7e92013-07-31 21:00:18 +000091 __attribute__((pcs("aapcs"))) functype pcsfunc; // expected-warning {{calling convention 'pcs' ignored for this target}}
Douglas Gregor5f970ee2010-05-04 18:18:31 +000092 };
93
94 void f(X<int> x) {
Reid Klecknerc66e7e92013-07-31 21:00:18 +000095 (void)x.func1(1, 2);
96 (void)x.func2(1, 2);
Reid Kleckner5b926962013-07-19 19:51:03 +000097 (void)x.stdfunc1(1, 2);
98 (void)x.stdfunc2(1, 2);
Reid Klecknerc66e7e92013-07-31 21:00:18 +000099 (void)x.pcsfunc(1, 2);
Douglas Gregor5f970ee2010-05-04 18:18:31 +0000100 }
101}