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