1 // RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple -emit-llvm-only %s
2 // RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple -emit-llvm-only -std=c++98 %s
3 // RUN: %clang_cc1 -debug-info-kind=limited -triple %itanium_abi_triple -emit-llvm-only -std=c++11 %s
4 // Check that we don't crash.
5 // PR12305, PR12315
6
7 # 1 "a.h" 3
8 template < typename T1 > struct Types1
9 {
10 typedef T1 Head;
11 };
12 template < typename > struct Types;
13 template < template < typename > class Tmpl > struct TemplateSel
14 {
15 template < typename T > struct Bind
16 {
17 typedef Tmpl < T > type;
18 };
19 };
20 template < typename > struct NoneT;
21 template < template < typename > class T1, template < typename > class > struct Templates2
22 {
23 typedef TemplateSel < T1 > Head;
24 };
25 template < template < typename > class, template < typename > class =
26 NoneT, template < typename > class = NoneT, template < typename > class =
27 NoneT > struct Templates;
28 template < template < typename > class T1,
29 template < typename > class T2 > struct Templates <T1, T2 >
30 {
31 typedef Templates2 < T1, T2 > type;
32 };
33 template < typename T > struct TypeList
34 {
35 typedef Types1 < T > type;
36 };
37 template < template < typename > class, class TestSel,
38 typename Types > class TypeParameterizedTest
39 {
Register()40 public:static bool Register ()
41 {
42 typedef typename Types::Head Type;
43 typename TestSel::template Bind < Type >::type TestClass;
44 }};
45
46 template < template < typename > class Fixture, typename Tests,
47 typename Types > class TypeParameterizedTestCase
48 {
Register(char *,char *,int *)49 public:static bool Register (char *, char *, int *)
50 {
51 typedef typename Tests::Head Head;
52 TypeParameterizedTest < Fixture, Head, Types >::Register;
53 }};
54
55 template < typename > class TypedTestP1
56 {
57 };
58
59 namespace gtest_case_TypedTestP1_
60 {
61 template < typename gtest_TypeParam_ > class A:TypedTestP1 <
62 gtest_TypeParam_ >
63 {
64 };
65 template < typename gtest_TypeParam_ > class B:TypedTestP1 <
66 gtest_TypeParam_ >
67 {
68 };
69 typedef Templates < A >::type gtest_AllTests_;
70 }
71
72 template < typename > class TypedTestP2
73 {
74 };
75
76 namespace gtest_case_TypedTestP2_
77 {
78 template < typename gtest_TypeParam_ > class A:TypedTestP2 <
79 gtest_TypeParam_ >
80 {
81 };
82 typedef Templates < A >::type gtest_AllTests_;
83 }
84
85 bool gtest_Int_TypedTestP1 =
86 TypeParameterizedTestCase < TypedTestP1,
87 gtest_case_TypedTestP1_::gtest_AllTests_,
88 TypeList < int >::type >::Register ("Int", "TypedTestP1", 0);
89 bool gtest_Int_TypedTestP2 =
90 TypeParameterizedTestCase < TypedTestP2,
91 gtest_case_TypedTestP2_::gtest_AllTests_,
92 TypeList < Types < int > >::type >::Register ("Int", "TypedTestP2", 0);
93
94 template < typename _Tp > struct new_allocator
95 {
96 typedef _Tp *pointer;
97 template < typename > struct rebind {
98 typedef new_allocator other;
99 };
100 };
101 template < typename _Tp > struct allocator:new_allocator < _Tp > {
102 };
103 template < typename _Tp, typename _Alloc > struct _Vector_base {
104 typedef typename _Alloc::template rebind < _Tp >::other _Tp_alloc_type;
105 struct _Vector_impl {
106 typename _Tp_alloc_type::pointer _M_end_of_storage;
107 };
_Vector_base_Vector_base108 _Vector_base () {
109 foo((int *) this->_M_impl._M_end_of_storage);
110 }
111 void foo(int *);
112 _Vector_impl _M_impl;
113 };
114 template < typename _Tp, typename _Alloc =
115 allocator < _Tp > >struct vector:_Vector_base < _Tp, _Alloc > { };
116
117
118 template < class T> struct HHH {};
119 struct DDD { int x_;};
120 struct Data;
121 struct X1;
122 struct CCC:DDD { virtual void xxx (HHH < X1 >); };
123 template < class SSS > struct EEE:vector < HHH < SSS > > { };
124 template < class SSS, class = EEE < SSS > >class FFF { };
125 template < class SSS, class GGG = EEE < SSS > >class AAA:FFF <GGG> { };
126 class BBB:virtual CCC {
127 void xxx (HHH < X1 >);
128 vector < HHH < X1 > >aaa;
129 };
130 class ZZZ:AAA < Data >, BBB { virtual ZZZ *ppp () ; };
ppp()131 ZZZ * ZZZ::ppp () { return new ZZZ; }
132
133 namespace std
134 {
135 template < class, class > struct pair;
136 }
137 namespace __gnu_cxx {
138 template < typename > class new_allocator;
139 }
140 namespace std {
141 template < typename _Tp > class allocator:__gnu_cxx::new_allocator < _Tp > {
142 };
143 template < typename, typename > struct _Vector_base {
144 };
145 template < typename _Tp, typename _Alloc = std::allocator < _Tp > >class vector:_Vector_base < _Tp,
146 _Alloc
147 > {
148 };
149 }
150
151 namespace
152 std {
153 template <
154 typename,
155 typename > struct unary_function;
156 template <
157 typename,
158 typename,
159 typename > struct binary_function;
160 template <
161 typename
162 _Tp > struct equal_to:
163 binary_function <
164 _Tp,
165 _Tp,
166 bool > {
167 };
168 template <
169 typename
170 _Pair > struct _Select1st:
171 unary_function <
172 _Pair,
173 typename
174 _Pair::first_type > {
175 };
176 }
177 # 1 "f.h" 3
178 using
179 std::pair;
180 namespace
181 __gnu_cxx {
182 template <
183 class > struct hash;
184 template <
185 class,
186 class,
187 class,
188 class,
189 class
190 _EqualKey,
191 class >
192 class
193 hashtable {
194 public:
195 typedef _EqualKey
196 key_equal;
197 typedef void key_type;
198 };
199 using
200 std::equal_to;
201 using
202 std::allocator;
203 using
204 std::_Select1st;
205 template < class _Key, class _Tp, class _HashFn =
206 hash < _Key >, class _EqualKey = equal_to < _Key >, class _Alloc =
207 allocator < _Tp > >class hash_map {
208 typedef
209 hashtable <
210 pair <
211 _Key,
212 _Tp >,
213 _Key,
214 _HashFn,
215 _Select1st <
216 pair <
217 _Key,
218 _Tp > >,
219 _EqualKey,
220 _Alloc >
221 _Ht;
222 public:
223 typedef typename _Ht::key_type key_type;
224 typedef typename
225 _Ht::key_equal
226 key_equal;
227 };
228 }
229 using
230 __gnu_cxx::hash_map;
231 class
232 C2;
233 template < class > class scoped_ptr {
234 };
235 namespace {
236 class
237 AAA {
238 protected:
~AAA()239 virtual ~
240 AAA () {
241 }};
242 }
243 template < typename > class EEE;
244 template < typename CCC, typename =
245 typename CCC::key_equal, typename =
246 EEE < CCC > >class III {
247 };
248 namespace
249 util {
250 class
251 EEE {
252 };
253 }
254 namespace {
255 class
256 C1:
257 util::EEE {
258 public:
259 class
260 C3:
261 AAA {
262 struct FFF;
263 typedef
264 III <
265 hash_map <
266 C2,
267 FFF > >
268 GGG;
269 GGG
270 aaa;
271 friend
272 C1;
273 };
274 void
275 HHH (C3::GGG &);
276 };
277 }
278 namespace
279 n1 {
280 class
281 Test {
282 };
283 template <
284 typename >
285 class
286 C7 {
287 };
288 class
289 C4:
290 n1::Test {
291 vector <
292 C1::C3 * >
293 a1;
294 };
295 enum C5 { };
296 class
297 C6:
298 C4,
299 n1::C7 <
300 C5 > {
301 };
302 class
303 C8:
304 C6 {
305 };
306 class
307 C9:
308 C8 {
309 void
310 TestBody ();
311 };
312 void
TestBody()313 C9::TestBody () {
314 scoped_ptr < C1::C3 > context;
315 }
316 }
317