Douglas Gregor | 025291b | 2010-07-01 00:21:21 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 | |
| 3 | // <rdar://problem/8124080> |
| 4 | template<typename _Alloc> class allocator; |
| 5 | template<class _CharT> struct char_traits; |
| 6 | template<typename _CharT, typename _Traits = char_traits<_CharT>, |
| 7 | typename _Alloc = allocator<_CharT> > |
| 8 | class basic_string; |
| 9 | template<typename _CharT, typename _Traits, typename _Alloc> |
| 10 | const typename basic_string<_CharT, _Traits, _Alloc>::size_type |
| 11 | basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_max_size // expected-error{{no member named '_Rep' in 'basic_string<_CharT, _Traits, _Alloc>'}} |
| 12 | = (((npos - sizeof(_Rep_base))/sizeof(_CharT)) - 1) / 4; |
| 13 | |
| 14 | // PR7118 |
| 15 | template<typename T> |
| 16 | class Foo { |
| 17 | class Bar; |
| 18 | void f() { |
| 19 | Bar i; |
| 20 | } |
| 21 | }; |
Argyrios Kyrtzidis | 6a622df | 2010-10-30 01:06:23 +0000 | [diff] [blame] | 22 | |
| 23 | // PR7625 |
| 24 | template<typename T> struct a : T { |
| 25 | struct x : T { |
| 26 | int aa() { return p; } // expected-error{{use of undeclared identifier 'p'}} |
| 27 | }; |
| 28 | }; |
Argyrios Kyrtzidis | d86132d | 2010-10-30 01:06:26 +0000 | [diff] [blame] | 29 | |
| 30 | // rdar://8605381 |
| 31 | namespace rdar8605381 { |
| 32 | struct X {}; |
| 33 | |
| 34 | struct Y { // expected-note{{candidate}} |
| 35 | Y(); |
| 36 | }; |
| 37 | |
| 38 | struct { |
| 39 | Y obj; |
| 40 | } objs[] = { |
| 41 | new Y // expected-error{{no viable conversion}} |
| 42 | }; |
| 43 | } |
Argyrios Kyrtzidis | 2c4792c | 2010-11-05 23:25:18 +0000 | [diff] [blame] | 44 | |
| 45 | // http://llvm.org/PR8234 |
| 46 | namespace PR8234 { |
| 47 | template<typename Signature> |
| 48 | class callback |
| 49 | { |
| 50 | }; |
| 51 | |
| 52 | template<typename R , typename ARG_TYPE0> |
| 53 | class callback<R( ARG_TYPE0)> |
| 54 | { |
| 55 | public: |
| 56 | callback() {} |
| 57 | }; |
| 58 | |
| 59 | template< typename ARG_TYPE0> |
| 60 | class callback<void( ARG_TYPE0)> |
| 61 | { |
| 62 | public: |
| 63 | callback() {} |
| 64 | }; |
| 65 | |
| 66 | void f() |
| 67 | { |
| 68 | callback<void(const int&)> op; |
| 69 | } |
| 70 | } |
Rafael Espindola | ac6a858 | 2011-01-20 16:11:21 +0000 | [diff] [blame] | 71 | |
| 72 | namespace PR9007 { |
| 73 | struct bar { |
| 74 | enum xxx { |
| 75 | yyy = sizeof(struct foo*) |
| 76 | }; |
| 77 | foo *xxx(); |
Rafael Espindola | f3beabf | 2011-01-22 15:34:07 +0000 | [diff] [blame] | 78 | }; |
| 79 | } |
| 80 | |
| 81 | namespace PR9026 { |
| 82 | class InfallibleTArray { |
| 83 | }; |
| 84 | class Variant; |
| 85 | class CompVariant { |
| 86 | operator const InfallibleTArray&() const; |
| 87 | }; |
| 88 | class Variant { |
| 89 | operator const CompVariant&() const; |
| 90 | }; |
| 91 | void Write(const Variant& __v); |
| 92 | void Write(const InfallibleTArray& __v); |
| 93 | Variant x; |
| 94 | void Write2() { |
| 95 | Write(x); |
| 96 | } |
Rafael Espindola | ac6a858 | 2011-01-20 16:11:21 +0000 | [diff] [blame] | 97 | } |
Douglas Gregor | 9a30c99 | 2011-07-05 16:13:20 +0000 | [diff] [blame] | 98 | |
| 99 | namespace PR10270 { |
| 100 | template<typename T> class C; |
| 101 | template<typename T> void f() { |
| 102 | if (C<T> == 1) // expected-error{{expected unqualified-id}} \ |
| 103 | // expected-error{{invalid '==' at end of declaration}} |
| 104 | return; |
| 105 | } |
| 106 | } |
Argyrios Kyrtzidis | ee7af50 | 2012-07-19 16:08:28 +0000 | [diff] [blame] | 107 | |
| 108 | namespace rdar11806334 { |
| 109 | |
| 110 | class cc_YCbCr; |
| 111 | |
| 112 | class cc_rgb |
| 113 | { |
| 114 | public: |
| 115 | cc_rgb( uint p ); // expected-error {{unknown type name}} |
| 116 | cc_rgb( cc_YCbCr v_in ); |
| 117 | }; |
| 118 | |
| 119 | class cc_hsl |
| 120 | { |
| 121 | public: |
| 122 | cc_rgb rgb(); |
| 123 | cc_YCbCr YCbCr(); |
| 124 | }; |
| 125 | |
| 126 | class cc_YCbCr |
| 127 | { |
| 128 | public: |
| 129 | cc_YCbCr( const cc_rgb v_in ); |
| 130 | }; |
| 131 | |
| 132 | cc_YCbCr cc_hsl::YCbCr() |
| 133 | { |
| 134 | cc_YCbCr v_out = cc_YCbCr( rgb()); |
| 135 | return v_out; |
| 136 | } |
| 137 | |
| 138 | } |
Rafael Espindola | 3954d39 | 2012-10-27 04:54:49 +0000 | [diff] [blame] | 139 | |
| 140 | namespace test1 { |
| 141 | int getString(const int*); |
| 142 | template<int a> class ELFObjectFile { |
| 143 | const int* sh; |
| 144 | ELFObjectFile() { |
| 145 | switch (*sh) { |
| 146 | } |
| 147 | int SectionName(getString(sh)); |
| 148 | } |
| 149 | }; |
| 150 | } |
Rafael Espindola | 1a7b2e9 | 2012-10-28 02:25:27 +0000 | [diff] [blame] | 151 | |
| 152 | namespace test2 { |
| 153 | struct fltSemantics ; |
| 154 | const fltSemantics &foobar(); |
| 155 | void VisitCastExpr(int x) { |
| 156 | switch (x) { |
| 157 | case 42: |
| 158 | const fltSemantics &Sem = foobar(); |
| 159 | } |
| 160 | } |
| 161 | } |
Rafael Espindola | ef4b666 | 2012-11-01 14:32:20 +0000 | [diff] [blame] | 162 | |
| 163 | namespace test3 { |
| 164 | struct nsCSSRect { |
| 165 | }; |
| 166 | static int nsCSSRect::* sides; |
| 167 | nsCSSRect dimenX; |
| 168 | void ParseBoxCornerRadii(int y) { |
| 169 | switch (y) { |
| 170 | } |
| 171 | int& x = dimenX.*sides; |
| 172 | } |
| 173 | } |
Serge Pavlov | 1e75a1a | 2013-09-04 04:50:29 +0000 | [diff] [blame] | 174 | |
| 175 | namespace pr16964 { |
| 176 | template<typename> struct bs { |
| 177 | bs(); |
| 178 | static int* member(); |
| 179 | member(); // expected-error{{C++ requires a type specifier for all declarations}} |
| 180 | static member(); // expected-error{{C++ requires a type specifier for all declarations}} |
| 181 | static int* member(int); |
| 182 | }; |
| 183 | |
| 184 | template<typename T> bs<T>::bs() { member; } |
| 185 | |
| 186 | bs<int> test() { |
| 187 | return bs<int>(); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | namespace pr12791 { |
| 192 | template<class _Alloc> class allocator {}; |
| 193 | template<class _CharT> struct char_traits; |
| 194 | struct input_iterator_tag {}; |
| 195 | struct forward_iterator_tag : public input_iterator_tag {}; |
| 196 | |
| 197 | template<typename _CharT, typename _Traits, typename _Alloc> struct basic_string { |
| 198 | struct _Alloc_hider : _Alloc {}; |
| 199 | mutable _Alloc_hider _M_dataplus; |
| 200 | template<class _InputIterator> basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a = _Alloc()); |
| 201 | template<class _InIterator> static _CharT* _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a, input_iterator_tag); |
| 202 | template<class _FwdIterator> static _CharT* _S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a, forward_iterator_tag); |
| 203 | static _CharT* _S_construct(size_type __req, _CharT __c, const _Alloc& __a); // expected-error{{unknown type name 'size_type'}} |
| 204 | }; |
| 205 | |
| 206 | template<typename _CharT, typename _Traits, typename _Alloc> |
| 207 | template<typename _InputIterator> |
| 208 | basic_string<_CharT, _Traits, _Alloc>:: basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a) |
| 209 | : _M_dataplus(_S_construct(__beg, __end, __a), __a) {} |
| 210 | |
| 211 | template<typename _CharT, typename _Traits = char_traits<_CharT>, typename _Alloc = allocator<_CharT> > struct basic_stringbuf { |
| 212 | typedef _CharT char_type; |
| 213 | typedef basic_string<char_type, _Traits, _Alloc> __string_type; |
| 214 | typedef typename __string_type::size_type __size_type; |
| 215 | __string_type str() const {__string_type((char_type*)0,(char_type*)0);} |
| 216 | }; |
| 217 | |
| 218 | template class basic_stringbuf<char>; |
| 219 | } |
| 220 | |
Stephen Hines | 651f13c | 2014-04-23 16:59:28 -0700 | [diff] [blame] | 221 | namespace pr16989 { |
| 222 | class C { |
| 223 | template <class T> |
| 224 | C tpl_mem(T *) { return } // expected-error{{expected expression}} |
| 225 | void mem(int *p) { |
| 226 | tpl_mem(p); |
| 227 | } |
| 228 | }; |
| 229 | class C2 { |
| 230 | void f(); |
| 231 | }; |
| 232 | void C2::f() {} |
| 233 | } |
Stephen Hines | 176edba | 2014-12-01 14:53:08 -0800 | [diff] [blame^] | 234 | |
| 235 | namespace pr20660 { |
| 236 | appendList(int[]...); // expected-error {{C++ requires a type specifier for all declarations}} |
| 237 | appendList(int[]...) { } // expected-error {{C++ requires a type specifier for all declarations}} |
| 238 | } |
| 239 | |