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