instantiate-function-params.cpp 3.5 KB

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