blob: a80587d8405b3fba4c964632fbb14b86f5be9d59 [file] [log] [blame]
Douglas Gregor5a5fcd82010-07-01 00:21:21 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Charles Lie7cbb3e2015-11-17 20:25:05 +00002// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
Douglas Gregor5a5fcd82010-07-01 00:21:21 +00004
5// <rdar://problem/8124080>
6template<typename _Alloc> class allocator;
7template<class _CharT> struct char_traits;
8template<typename _CharT, typename _Traits = char_traits<_CharT>,
9 typename _Alloc = allocator<_CharT> >
10class basic_string;
11template<typename _CharT, typename _Traits, typename _Alloc>
12const typename basic_string<_CharT, _Traits, _Alloc>::size_type
13basic_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
17template<typename T>
18class Foo {
19 class Bar;
20 void f() {
21 Bar i;
22 }
23};
Argyrios Kyrtzidisb5488f42010-10-30 01:06:23 +000024
25// PR7625
26template<typename T> struct a : T {
27 struct x : T {
28 int aa() { return p; } // expected-error{{use of undeclared identifier 'p'}}
29 };
30};
Argyrios Kyrtzidis93513152010-10-30 01:06:26 +000031
32// rdar://8605381
33namespace rdar8605381 {
34struct X {};
35
Charles Lie7cbb3e2015-11-17 20:25:05 +000036struct 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 Kyrtzidis93513152010-10-30 01:06:26 +000041 Y();
42};
43
44struct {
45 Y obj;
46} objs[] = {
47 new Y // expected-error{{no viable conversion}}
48};
49}
Argyrios Kyrtzidis7d391552010-11-05 23:25:18 +000050
51// http://llvm.org/PR8234
52namespace PR8234 {
53template<typename Signature>
54class callback
55{
56};
57
58template<typename R , typename ARG_TYPE0>
59class callback<R( ARG_TYPE0)>
60{
61 public:
62 callback() {}
63};
64
65template< typename ARG_TYPE0>
66class callback<void( ARG_TYPE0)>
67{
68 public:
69 callback() {}
70};
71
72void f()
73{
74 callback<void(const int&)> op;
75}
76}
Rafael Espindolaec4b30a2011-01-20 16:11:21 +000077
78namespace PR9007 {
79 struct bar {
80 enum xxx {
81 yyy = sizeof(struct foo*)
82 };
83 foo *xxx();
Rafael Espindolab53c03b2011-01-22 15:34:07 +000084 };
85}
86
87namespace 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 Espindolaec4b30a2011-01-20 16:11:21 +0000103}
Douglas Gregor1fe12c92011-07-05 16:13:20 +0000104
105namespace PR10270 {
106 template<typename T> class C;
107 template<typename T> void f() {
Richard Smith03a4aa32016-06-23 19:02:52 +0000108 if (C<T> == 1) // expected-error{{expected unqualified-id}}
Douglas Gregor1fe12c92011-07-05 16:13:20 +0000109 return;
110 }
111}
Argyrios Kyrtzidisac4cdc82012-07-19 16:08:28 +0000112
113namespace rdar11806334 {
114
115class cc_YCbCr;
116
117class cc_rgb
118{
119 public:
120 cc_rgb( uint p ); // expected-error {{unknown type name}}
121 cc_rgb( cc_YCbCr v_in );
122};
123
124class cc_hsl
125{
126 public:
127 cc_rgb rgb();
128 cc_YCbCr YCbCr();
129};
130
131class cc_YCbCr
132{
133 public:
134 cc_YCbCr( const cc_rgb v_in );
135};
136
137cc_YCbCr cc_hsl::YCbCr()
138{
139 cc_YCbCr v_out = cc_YCbCr( rgb());
140 return v_out;
141}
142
143}
Rafael Espindolabb5d47e2012-10-27 04:54:49 +0000144
145namespace 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 Espindolac74634f2012-10-28 02:25:27 +0000156
157namespace 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 Espindola973aa202012-11-01 14:32:20 +0000167
168namespace 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 Pavlov82605302013-09-04 04:50:29 +0000179
180namespace pr16964 {
181 template<typename> struct bs {
182 bs();
Nico Weber4486d612015-02-18 05:19:40 +0000183 static int* member(); // expected-note{{possible target}}
Serge Pavlov82605302013-09-04 04:50:29 +0000184 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 Weber4486d612015-02-18 05:19:40 +0000186 static int* member(int); // expected-note{{possible target}}
Serge Pavlov82605302013-09-04 04:50:29 +0000187 };
188
Nico Weber4486d612015-02-18 05:19:40 +0000189 template<typename T> bs<T>::bs() { member; } // expected-error{{did you mean to call it}}
Serge Pavlov82605302013-09-04 04:50:29 +0000190
191 bs<int> test() {
Nico Weber4486d612015-02-18 05:19:40 +0000192 return bs<int>(); // expected-note{{in instantiation}}
Serge Pavlov82605302013-09-04 04:50:29 +0000193 }
194}
195
196namespace 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 Weber4486d612015-02-18 05:19:40 +0000203 struct _Alloc_hider : _Alloc { _Alloc_hider(_CharT*, const _Alloc&); };
Serge Pavlov82605302013-09-04 04:50:29 +0000204 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 Weber4486d612015-02-18 05:19:40 +0000214 : _M_dataplus(_S_construct(__beg, __end, __a, input_iterator_tag()), __a) {}
Serge Pavlov82605302013-09-04 04:50:29 +0000215
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 Pavlov82605302013-09-04 04:50:29 +0000219 __string_type str() const {__string_type((char_type*)0,(char_type*)0);}
220 };
221
222 template class basic_stringbuf<char>;
223}
224
Serge Pavlovf79bd5c2013-12-04 03:51:59 +0000225namespace 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 Voufo2e846502014-08-29 21:08:16 +0000238
239namespace 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