Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / SemaCXX / crashes.cpp
blob41c30fffb80a70956873dc25f94bc4d1b0f191db
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
5 template<typename _Alloc> class allocator;
6 template<class _CharT> struct char_traits;
7 template<typename _CharT, typename _Traits = char_traits<_CharT>,
8 typename _Alloc = allocator<_CharT> >
9 class basic_string;
10 template<typename _CharT, typename _Traits, typename _Alloc>
11 const typename basic_string<_CharT, _Traits, _Alloc>::size_type
12 basic_string<_CharT, _Traits, _Alloc>::_Rep::_S_max_size // expected-error{{no member named '_Rep' in 'basic_string<_CharT, _Traits, _Alloc>'}}
13 = (((npos - sizeof(_Rep_base))/sizeof(_CharT)) - 1) / 4;
15 // PR7118
16 template<typename T>
17 class Foo {
18 class Bar;
19 void f() {
20 Bar i;
24 // PR7625
25 template<typename T> struct a : T {
26 struct x : T {
27 int aa() { return p; } // expected-error{{use of undeclared identifier 'p'}}
31 namespace rdar8605381 {
32 struct X {};
34 struct Y { // expected-note{{candidate constructor (the implicit copy constructor) not viable}}
35 #if __cplusplus >= 201103L // C++11 or later
36 // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
37 #endif
39 Y();
42 struct {
43 Y obj;
44 } objs[] = {
45 new Y // expected-error{{no viable conversion}}
49 // http://llvm.org/PR8234
50 namespace PR8234 {
51 template<typename Signature>
52 class callback
56 template<typename R , typename ARG_TYPE0>
57 class callback<R( ARG_TYPE0)>
59 public:
60 callback() {}
63 template< typename ARG_TYPE0>
64 class callback<void( ARG_TYPE0)>
66 public:
67 callback() {}
70 void f()
72 callback<void(const int&)> op;
76 namespace PR9007 {
77 struct bar {
78 enum xxx {
79 yyy = sizeof(struct foo*)
81 foo *xxx();
85 namespace PR9026 {
86 class InfallibleTArray {
88 class Variant;
89 class CompVariant {
90 operator const InfallibleTArray&() const;
92 class Variant {
93 operator const CompVariant&() const;
95 void Write(const Variant& __v);
96 void Write(const InfallibleTArray& __v);
97 Variant x;
98 void Write2() {
99 Write(x);
103 namespace PR10270 {
104 template<typename T> class C;
105 template<typename T> void f() {
106 if (C<T> == 1) // expected-error{{expected unqualified-id}}
107 return;
111 namespace rdar11806334 {
113 class cc_YCbCr;
115 class cc_rgb
117 public:
118 cc_rgb( uint p ); // expected-error {{unknown type name}}
119 cc_rgb( cc_YCbCr v_in );
122 class cc_hsl
124 public:
125 cc_rgb rgb();
126 cc_YCbCr YCbCr();
129 class cc_YCbCr
131 public:
132 cc_YCbCr( const cc_rgb v_in );
135 cc_YCbCr cc_hsl::YCbCr()
137 cc_YCbCr v_out = cc_YCbCr( rgb());
138 return v_out;
143 namespace test1 {
144 int getString(const int*);
145 template<int a> class ELFObjectFile {
146 const int* sh;
147 ELFObjectFile() {
148 switch (*sh) {
150 int SectionName(getString(sh));
155 namespace test2 {
156 struct fltSemantics ;
157 const fltSemantics &foobar();
158 void VisitCastExpr(int x) {
159 switch (x) {
160 case 42:
161 const fltSemantics &Sem = foobar();
166 namespace test3 {
167 struct nsCSSRect {
169 static int nsCSSRect::* sides;
170 nsCSSRect dimenX;
171 void ParseBoxCornerRadii(int y) {
172 switch (y) {
174 int& x = dimenX.*sides;
178 namespace pr16964 {
179 template<typename> struct bs {
180 bs();
181 static int* member(); // expected-note{{possible target}}
182 member(); // expected-error{{a type specifier is required for all declarations}}
183 static member(); // expected-error{{a type specifier is required for all declarations}}
184 static int* member(int); // expected-note{{possible target}}
187 template<typename T> bs<T>::bs() { member; } // expected-error{{did you mean to call it}}
189 bs<int> test() {
190 return bs<int>(); // expected-note{{in instantiation}}
194 namespace pr12791 {
195 template<class _Alloc> class allocator {};
196 template<class _CharT> struct char_traits;
197 struct input_iterator_tag {};
198 struct forward_iterator_tag : public input_iterator_tag {};
200 template<typename _CharT, typename _Traits, typename _Alloc> struct basic_string {
201 struct _Alloc_hider : _Alloc { _Alloc_hider(_CharT*, const _Alloc&); };
202 mutable _Alloc_hider _M_dataplus;
203 template<class _InputIterator> basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a = _Alloc());
204 template<class _InIterator> static _CharT* _S_construct(_InIterator __beg, _InIterator __end, const _Alloc& __a, input_iterator_tag);
205 template<class _FwdIterator> static _CharT* _S_construct(_FwdIterator __beg, _FwdIterator __end, const _Alloc& __a, forward_iterator_tag);
206 static _CharT* _S_construct(size_type __req, _CharT __c, const _Alloc& __a); // expected-error{{unknown type name 'size_type'}}
209 template<typename _CharT, typename _Traits, typename _Alloc>
210 template<typename _InputIterator>
211 basic_string<_CharT, _Traits, _Alloc>:: basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a)
212 : _M_dataplus(_S_construct(__beg, __end, __a, input_iterator_tag()), __a) {}
214 template<typename _CharT, typename _Traits = char_traits<_CharT>, typename _Alloc = allocator<_CharT> > struct basic_stringbuf {
215 typedef _CharT char_type;
216 typedef basic_string<char_type, _Traits, _Alloc> __string_type;
217 __string_type str() const {__string_type((char_type*)0,(char_type*)0);}
220 template class basic_stringbuf<char>;
223 namespace pr16989 {
224 class C {
225 template <class T>
226 C tpl_mem(T *) { return } // expected-error{{expected expression}}
227 void mem(int *p) {
228 tpl_mem(p);
231 class C2 {
232 void f();
234 void C2::f() {}
237 namespace pr20660 {
238 appendList(int[]...); // expected-error {{a type specifier is required for all declarations}}
239 appendList(int[]...) { } // expected-error {{a type specifier is required for all declarations}}