1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
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;
f()20 void f() {
21 Bar i;
22 }
23 };
24
25 // PR7625
26 template<typename T> struct a : T {
27 struct x : T {
aaa::x28 int aa() { return p; } // expected-error{{use of undeclared identifier 'p'}}
29 };
30 };
31
32 // rdar://8605381
33 namespace rdar8605381 {
34 struct X {};
35
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
41 Y();
42 };
43
44 struct {
45 Y obj;
46 } objs[] = {
47 new Y // expected-error{{no viable conversion}}
48 };
49 }
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:
callback()62 callback() {}
63 };
64
65 template< typename ARG_TYPE0>
66 class callback<void( ARG_TYPE0)>
67 {
68 public:
callback()69 callback() {}
70 };
71
f()72 void f()
73 {
74 callback<void(const int&)> op;
75 }
76 }
77
78 namespace PR9007 {
79 struct bar {
80 enum xxx {
81 yyy = sizeof(struct foo*)
82 };
83 foo *xxx();
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;
Write2()100 void Write2() {
101 Write(x);
102 }
103 }
104
105 namespace PR10270 {
106 template<typename T> class C;
f()107 template<typename T> void f() {
108 if (C<T> == 1) // expected-error{{expected unqualified-id}} \
109 // expected-error{{invalid '==' at end of declaration}}
110 return;
111 }
112 }
113
114 namespace rdar11806334 {
115
116 class cc_YCbCr;
117
118 class cc_rgb
119 {
120 public:
121 cc_rgb( uint p ); // expected-error {{unknown type name}}
122 cc_rgb( cc_YCbCr v_in );
123 };
124
125 class cc_hsl
126 {
127 public:
128 cc_rgb rgb();
129 cc_YCbCr YCbCr();
130 };
131
132 class cc_YCbCr
133 {
134 public:
135 cc_YCbCr( const cc_rgb v_in );
136 };
137
YCbCr()138 cc_YCbCr cc_hsl::YCbCr()
139 {
140 cc_YCbCr v_out = cc_YCbCr( rgb());
141 return v_out;
142 }
143
144 }
145
146 namespace test1 {
147 int getString(const int*);
148 template<int a> class ELFObjectFile {
149 const int* sh;
ELFObjectFile()150 ELFObjectFile() {
151 switch (*sh) {
152 }
153 int SectionName(getString(sh));
154 }
155 };
156 }
157
158 namespace test2 {
159 struct fltSemantics ;
160 const fltSemantics &foobar();
VisitCastExpr(int x)161 void VisitCastExpr(int x) {
162 switch (x) {
163 case 42:
164 const fltSemantics &Sem = foobar();
165 }
166 }
167 }
168
169 namespace test3 {
170 struct nsCSSRect {
171 };
172 static int nsCSSRect::* sides;
173 nsCSSRect dimenX;
ParseBoxCornerRadii(int y)174 void ParseBoxCornerRadii(int y) {
175 switch (y) {
176 }
177 int& x = dimenX.*sides;
178 }
179 }
180
181 namespace pr16964 {
182 template<typename> struct bs {
183 bs();
184 static int* member(); // expected-note{{possible target}}
185 member(); // expected-error{{C++ requires a type specifier for all declarations}}
186 static member(); // expected-error{{C++ requires a type specifier for all declarations}}
187 static int* member(int); // expected-note{{possible target}}
188 };
189
bs()190 template<typename T> bs<T>::bs() { member; } // expected-error{{did you mean to call it}}
191
test()192 bs<int> test() {
193 return bs<int>(); // expected-note{{in instantiation}}
194 }
195 }
196
197 namespace pr12791 {
198 template<class _Alloc> class allocator {};
199 template<class _CharT> struct char_traits;
200 struct input_iterator_tag {};
201 struct forward_iterator_tag : public input_iterator_tag {};
202
203 template<typename _CharT, typename _Traits, typename _Alloc> struct basic_string {
204 struct _Alloc_hider : _Alloc { _Alloc_hider(_CharT*, const _Alloc&); };
205 mutable _Alloc_hider _M_dataplus;
206 template<class _InputIterator> basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a = _Alloc());
207 template<class _InIterator> static _CharT* _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a, input_iterator_tag);
208 template<class _FwdIterator> static _CharT* _S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a, forward_iterator_tag);
209 static _CharT* _S_construct(size_type __req, _CharT __c, const _Alloc& __a); // expected-error{{unknown type name 'size_type'}}
210 };
211
212 template<typename _CharT, typename _Traits, typename _Alloc>
213 template<typename _InputIterator>
basic_string(_InputIterator __beg,_InputIterator __end,const _Alloc & __a)214 basic_string<_CharT, _Traits, _Alloc>:: basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a)
215 : _M_dataplus(_S_construct(__beg, __end, __a, input_iterator_tag()), __a) {}
216
217 template<typename _CharT, typename _Traits = char_traits<_CharT>, typename _Alloc = allocator<_CharT> > struct basic_stringbuf {
218 typedef _CharT char_type;
219 typedef basic_string<char_type, _Traits, _Alloc> __string_type;
strpr12791::basic_stringbuf220 __string_type str() const {__string_type((char_type*)0,(char_type*)0);}
221 };
222
223 template class basic_stringbuf<char>;
224 }
225
226 namespace pr16989 {
227 class C {
228 template <class T>
tpl_mem(T *)229 C tpl_mem(T *) { return } // expected-error{{expected expression}}
mem(int * p)230 void mem(int *p) {
231 tpl_mem(p);
232 }
233 };
234 class C2 {
235 void f();
236 };
f()237 void C2::f() {}
238 }
239
240 namespace pr20660 {
241 appendList(int[]...); // expected-error {{C++ requires a type specifier for all declarations}}
appendList(int[]...)242 appendList(int[]...) { } // expected-error {{C++ requires a type specifier for all declarations}}
243 }
244
245