deduction-crash.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. // RUN: not %clang_cc1 -fsyntax-only %s -std=c++11 2>&1| FileCheck %s
  2. // Note that the error count below doesn't matter. We just want to
  3. // make sure that the parser doesn't crash.
  4. // CHECK: 16 errors
  5. // PR7511
  6. template<a>
  7. struct int_;
  8. template<a>
  9. template<int,typename T1,typename>
  10. struct ac
  11. {
  12. typedef T1 ae
  13. };
  14. template<class>struct aaa
  15. {
  16. typedef ac<1,int,int>::ae ae
  17. };
  18. template<class>
  19. struct state_machine
  20. {
  21. typedef aaa<int>::ae aaa;
  22. int start()
  23. {
  24. ant(0);
  25. }
  26. template<class>
  27. struct region_processing_helper
  28. {
  29. template<class,int=0>
  30. struct In;
  31. template<int my>
  32. struct In<a::int_<aaa::a>,my>;
  33. template<class Event>
  34. int process(Event)
  35. {
  36. In<a::int_<0> > a;
  37. }
  38. }
  39. template<class Event>
  40. int ant(Event)
  41. {
  42. region_processing_helper<int>* helper;
  43. helper->process(0)
  44. }
  45. };
  46. int a()
  47. {
  48. state_machine<int> p;
  49. p.ant(0);
  50. }
  51. // PR9974
  52. template <int> struct enable_if;
  53. template <class > struct remove_reference ;
  54. template <class _Tp> struct remove_reference<_Tp&> ;
  55. template <class > struct __tuple_like;
  56. template <class _Tp, class _Up, int = __tuple_like<typename remove_reference<_Tp>::type>::value>
  57. struct __tuple_convertible;
  58. struct pair
  59. {
  60. template<class _Tuple, int = enable_if<__tuple_convertible<_Tuple, pair>::value>::type>
  61. pair(_Tuple&& );
  62. };
  63. template <class> struct basic_ostream;
  64. template <int>
  65. void endl( ) ;
  66. extern basic_ostream<char> cout;
  67. int operator<<( basic_ostream<char> , pair ) ;
  68. void register_object_imp ( )
  69. {
  70. cout << endl<1>;
  71. }
  72. // PR12933
  73. namespacae PR12933 {
  74. template<typename S>
  75. template<typename T>
  76. void function(S a, T b) {}
  77. int main() {
  78. function(0, 1);
  79. return 0;
  80. }
  81. }
  82. // A buildbot failure from libcxx
  83. namespace libcxx_test {
  84. template <class _Ptr, bool> struct __pointer_traits_element_type;
  85. template <class _Ptr> struct __pointer_traits_element_type<_Ptr, true>;
  86. template <template <class, class...> class _Sp, class _Tp, class ..._Args> struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> {
  87. typedef char type;
  88. };
  89. template <class T> struct B {};
  90. __pointer_traits_element_type<B<int>, true>::type x;
  91. }
  92. namespace PR14281_part1 {
  93. template <class P, int> struct A;
  94. template <class P> struct A<P, 1>;
  95. template <template <class, int> class S, class T> struct A<S<T, 1>, 1> {
  96. typedef char type;
  97. };
  98. template <class T, int i> struct B {};
  99. A<B<int, 1>, 1>::type x;
  100. }
  101. namespace PR14281_part2 {
  102. typedef decltype(nullptr) nullptr_t;
  103. template <class P, nullptr_t> struct A;
  104. template <class P> struct A<P, nullptr>;
  105. template <template <class, nullptr_t> class S, class T> struct A<S<T, nullptr>, nullptr> {
  106. typedef char type;
  107. };
  108. template <class T, nullptr_t i> struct B {};
  109. A<B<int, nullptr>, nullptr>::type x;
  110. }
  111. namespace PR14281_part3 {
  112. extern int some_decl;
  113. template <class P, int*> struct A;
  114. template <class P> struct A<P, &some_decl>;
  115. template <template <class, int*> class S, class T> struct A<S<T, &some_decl>, &some_decl> {
  116. typedef char type;
  117. };
  118. template <class T, int* i> struct B {};
  119. A<B<int, &some_decl>, &some_decl>::type x;
  120. }