Richard Smith | f8ba3fd | 2017-06-02 22:53:06 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only %s -std=c++1z -verify |
Douglas Gregor | 291e8ee | 2011-05-21 22:16:50 +0000 | [diff] [blame] | 2 | |
| 3 | // PR7511 |
Richard Smith | f8ba3fd | 2017-06-02 22:53:06 +0000 | [diff] [blame] | 4 | template<a> // expected-error +{{}} |
Douglas Gregor | 5f0e252 | 2010-07-14 23:14:12 +0000 | [diff] [blame] | 5 | struct int_; |
| 6 | |
Richard Smith | f8ba3fd | 2017-06-02 22:53:06 +0000 | [diff] [blame] | 7 | template<a> // expected-error +{{}} |
Douglas Gregor | 5f0e252 | 2010-07-14 23:14:12 +0000 | [diff] [blame] | 8 | template<int,typename T1,typename> |
| 9 | struct ac |
| 10 | { |
| 11 | typedef T1 ae |
| 12 | }; |
| 13 | |
| 14 | template<class>struct aaa |
| 15 | { |
Richard Smith | f8ba3fd | 2017-06-02 22:53:06 +0000 | [diff] [blame] | 16 | typedef ac<1,int,int>::ae ae // expected-error +{{}} |
Douglas Gregor | 5f0e252 | 2010-07-14 23:14:12 +0000 | [diff] [blame] | 17 | }; |
| 18 | |
| 19 | template<class> |
| 20 | struct state_machine |
| 21 | { |
| 22 | typedef aaa<int>::ae aaa; |
| 23 | int start() |
| 24 | { |
| 25 | ant(0); |
| 26 | } |
| 27 | |
| 28 | template<class> |
| 29 | struct region_processing_helper |
| 30 | { |
| 31 | template<class,int=0> |
| 32 | struct In; |
| 33 | |
| 34 | template<int my> |
Richard Smith | f8ba3fd | 2017-06-02 22:53:06 +0000 | [diff] [blame] | 35 | struct In<a::int_<aaa::a>,my>; // expected-error +{{}} |
Douglas Gregor | 5f0e252 | 2010-07-14 23:14:12 +0000 | [diff] [blame] | 36 | |
| 37 | template<class Event> |
| 38 | int process(Event) |
| 39 | { |
Richard Smith | f8ba3fd | 2017-06-02 22:53:06 +0000 | [diff] [blame] | 40 | In<a::int_<0> > a; // expected-error +{{}} |
Douglas Gregor | 5f0e252 | 2010-07-14 23:14:12 +0000 | [diff] [blame] | 41 | } |
Richard Smith | f8ba3fd | 2017-06-02 22:53:06 +0000 | [diff] [blame] | 42 | } // expected-error +{{}} |
Douglas Gregor | 5f0e252 | 2010-07-14 23:14:12 +0000 | [diff] [blame] | 43 | template<class Event> |
| 44 | int ant(Event) |
| 45 | { |
| 46 | region_processing_helper<int>* helper; |
Richard Smith | f8ba3fd | 2017-06-02 22:53:06 +0000 | [diff] [blame] | 47 | helper->process(0) // expected-error +{{}} |
Douglas Gregor | 5f0e252 | 2010-07-14 23:14:12 +0000 | [diff] [blame] | 48 | } |
| 49 | }; |
| 50 | |
| 51 | int a() |
| 52 | { |
| 53 | state_machine<int> p; |
| 54 | p.ant(0); |
| 55 | } |
Douglas Gregor | 291e8ee | 2011-05-21 22:16:50 +0000 | [diff] [blame] | 56 | |
| 57 | // PR9974 |
| 58 | template <int> struct enable_if; |
| 59 | template <class > struct remove_reference ; |
| 60 | template <class _Tp> struct remove_reference<_Tp&> ; |
| 61 | |
| 62 | template <class > struct __tuple_like; |
| 63 | |
| 64 | template <class _Tp, class _Up, int = __tuple_like<typename remove_reference<_Tp>::type>::value> |
| 65 | struct __tuple_convertible; |
| 66 | |
| 67 | struct pair |
| 68 | { |
| 69 | template<class _Tuple, int = enable_if<__tuple_convertible<_Tuple, pair>::value>::type> |
| 70 | pair(_Tuple&& ); |
| 71 | }; |
| 72 | |
| 73 | template <class> struct basic_ostream; |
| 74 | |
| 75 | template <int> |
| 76 | void endl( ) ; |
| 77 | |
| 78 | extern basic_ostream<char> cout; |
| 79 | |
Richard Smith | f8ba3fd | 2017-06-02 22:53:06 +0000 | [diff] [blame] | 80 | int operator<<( basic_ostream<char> , pair ) ; // expected-note +{{}} |
Douglas Gregor | 291e8ee | 2011-05-21 22:16:50 +0000 | [diff] [blame] | 81 | |
| 82 | void register_object_imp ( ) |
| 83 | { |
Richard Smith | f8ba3fd | 2017-06-02 22:53:06 +0000 | [diff] [blame] | 84 | cout << endl<1>; // expected-error +{{}} |
Douglas Gregor | 291e8ee | 2011-05-21 22:16:50 +0000 | [diff] [blame] | 85 | } |
Douglas Gregor | c5c01a6 | 2012-09-13 21:01:57 +0000 | [diff] [blame] | 86 | |
| 87 | // PR12933 |
Richard Smith | f8ba3fd | 2017-06-02 22:53:06 +0000 | [diff] [blame] | 88 | namespace PR12933 { |
| 89 | template<typename S> // expected-error +{{}} |
Douglas Gregor | c5c01a6 | 2012-09-13 21:01:57 +0000 | [diff] [blame] | 90 | template<typename T> |
| 91 | void function(S a, T b) {} |
| 92 | |
| 93 | int main() { |
Richard Smith | f8ba3fd | 2017-06-02 22:53:06 +0000 | [diff] [blame] | 94 | function(0, 1); // expected-error +{{}} |
Douglas Gregor | c5c01a6 | 2012-09-13 21:01:57 +0000 | [diff] [blame] | 95 | return 0; |
| 96 | } |
| 97 | } |
Eli Friedman | c681e5f | 2012-09-27 22:13:33 +0000 | [diff] [blame] | 98 | |
| 99 | // A buildbot failure from libcxx |
| 100 | namespace libcxx_test { |
| 101 | template <class _Ptr, bool> struct __pointer_traits_element_type; |
| 102 | template <class _Ptr> struct __pointer_traits_element_type<_Ptr, true>; |
| 103 | template <template <class, class...> class _Sp, class _Tp, class ..._Args> struct __pointer_traits_element_type<_Sp<_Tp, _Args...>, true> { |
| 104 | typedef char type; |
| 105 | }; |
| 106 | template <class T> struct B {}; |
| 107 | __pointer_traits_element_type<B<int>, true>::type x; |
| 108 | } |
Eli Friedman | 437313c | 2013-06-26 23:30:50 +0000 | [diff] [blame] | 109 | |
| 110 | namespace PR14281_part1 { |
| 111 | template <class P, int> struct A; |
| 112 | template <class P> struct A<P, 1>; |
| 113 | template <template <class, int> class S, class T> struct A<S<T, 1>, 1> { |
| 114 | typedef char type; |
| 115 | }; |
| 116 | template <class T, int i> struct B {}; |
| 117 | A<B<int, 1>, 1>::type x; |
| 118 | } |
| 119 | |
| 120 | namespace PR14281_part2 { |
| 121 | typedef decltype(nullptr) nullptr_t; |
| 122 | template <class P, nullptr_t> struct A; |
| 123 | template <class P> struct A<P, nullptr>; |
| 124 | template <template <class, nullptr_t> class S, class T> struct A<S<T, nullptr>, nullptr> { |
| 125 | typedef char type; |
| 126 | }; |
| 127 | template <class T, nullptr_t i> struct B {}; |
| 128 | A<B<int, nullptr>, nullptr>::type x; |
| 129 | } |
| 130 | |
| 131 | namespace PR14281_part3 { |
| 132 | extern int some_decl; |
| 133 | template <class P, int*> struct A; |
| 134 | template <class P> struct A<P, &some_decl>; |
| 135 | template <template <class, int*> class S, class T> struct A<S<T, &some_decl>, &some_decl> { |
| 136 | typedef char type; |
| 137 | }; |
| 138 | template <class T, int* i> struct B {}; |
| 139 | A<B<int, &some_decl>, &some_decl>::type x; |
| 140 | } |
Richard Smith | f8ba3fd | 2017-06-02 22:53:06 +0000 | [diff] [blame] | 141 | |
| 142 | namespace var_template_partial_spec_incomplete { |
| 143 | template<typename T> int n; |
| 144 | template<typename T, typename U = void> int n<T *>; // expected-error +{{}} expected-note {{}} |
| 145 | int k = n<void *>; |
| 146 | } |
Alex Lorenz | ddd279b | 2017-10-27 18:13:31 +0000 | [diff] [blame] | 147 | |
| 148 | namespace deduceFunctionSpecializationForInvalidOutOfLineFunction { |
| 149 | |
| 150 | template <typename InputT, typename OutputT> |
| 151 | struct SourceSelectionRequirement { |
| 152 | template<typename T> |
| 153 | OutputT evaluateSelectionRequirement(InputT &&Value) { |
| 154 | } |
| 155 | }; |
| 156 | |
| 157 | template <typename InputT, typename OutputT> |
| 158 | OutputT SourceSelectionRequirement<InputT, OutputT>:: |
| 159 | evaluateSelectionRequirement<void>(InputT &&Value) { // expected-error {{cannot specialize a member of an unspecialized template}} |
| 160 | return Value; |
| 161 | } |
| 162 | |
| 163 | } |