blob: b5bdae234445038539b5213a2160c193ff3fd654 [file] [log] [blame]
Richard Smith762bb9d2011-10-13 22:29:44 +00001// RUN: %clang_cc1 -std=c++11 -emit-llvm -triple=x86_64-apple-darwin9 -o - %s | FileCheck %s
Douglas Gregor46268672011-01-04 22:16:00 +00002
3template<unsigned I, typename ...Types>
4struct X { };
5
Douglas Gregor4fc48662011-01-13 16:39:34 +00006template<typename T> struct identity { };
7template<typename T> struct add_reference;
8template<typename ...Types> struct tuple { };
9template<int ...Values> struct int_tuple { };
10template<template<typename> class ...Templates> struct template_tuple { };
11
Douglas Gregor255c2692011-01-13 17:44:36 +000012// CHECK: define weak_odr void @_Z2f0IJEEv1XIXsZT_EJDpRT_EE
Douglas Gregor46268672011-01-04 22:16:00 +000013template<typename ...Types>
14void f0(X<sizeof...(Types), Types&...>) { }
15
16template void f0(X<0>);
17
Douglas Gregor255c2692011-01-13 17:44:36 +000018// CHECK: define weak_odr void @_Z2f0IJifdEEv1XIXsZT_EJDpRT_EE
Douglas Gregor46268672011-01-04 22:16:00 +000019template void f0<int, float, double>(X<3, int&, float&, double&>);
Douglas Gregor4fc48662011-01-13 16:39:34 +000020
21// Mangling for template argument packs
22template<typename ...Types> void f1() {}
23// CHECK: define weak_odr void @_Z2f1IJEEvv
24template void f1<>();
25// CHECK: define weak_odr void @_Z2f1IJiEEvv
26template void f1<int>();
27// CHECK: define weak_odr void @_Z2f1IJifEEvv
28template void f1<int, float>();
29
30// Mangling function parameter packs
31template<typename ...Types> void f2(Types...) {}
Douglas Gregor255c2692011-01-13 17:44:36 +000032// CHECK: define weak_odr void @_Z2f2IJEEvDpT_
Douglas Gregor4fc48662011-01-13 16:39:34 +000033template void f2<>();
Douglas Gregor255c2692011-01-13 17:44:36 +000034// CHECK: define weak_odr void @_Z2f2IJiEEvDpT_
Douglas Gregor4fc48662011-01-13 16:39:34 +000035template void f2<int>(int);
Douglas Gregor255c2692011-01-13 17:44:36 +000036// CHECK: define weak_odr void @_Z2f2IJifEEvDpT_
Douglas Gregor4fc48662011-01-13 16:39:34 +000037template void f2<int, float>(int, float);
38
39// Mangling non-trivial function parameter packs
40template<typename ...Types> void f3(const Types *...) {}
Douglas Gregor255c2692011-01-13 17:44:36 +000041// CHECK: define weak_odr void @_Z2f3IJEEvDpPKT_
Douglas Gregor4fc48662011-01-13 16:39:34 +000042template void f3<>();
Douglas Gregor255c2692011-01-13 17:44:36 +000043// CHECK: define weak_odr void @_Z2f3IJiEEvDpPKT_
Douglas Gregor4fc48662011-01-13 16:39:34 +000044template void f3<int>(const int*);
Douglas Gregor255c2692011-01-13 17:44:36 +000045// CHECK: define weak_odr void @_Z2f3IJifEEvDpPKT_
Douglas Gregor4fc48662011-01-13 16:39:34 +000046template void f3<int, float>(const int*, const float*);
47
48// Mangling of type pack expansions in a template argument
49template<typename ...Types> tuple<Types...> f4() {}
Douglas Gregor255c2692011-01-13 17:44:36 +000050// CHECK: define weak_odr void @_Z2f4IJifdEE5tupleIJDpT_EEv
Douglas Gregor4fc48662011-01-13 16:39:34 +000051template tuple<int, float, double> f4();
52
53// Mangling of type pack expansions in a function type
54template<typename R, typename ...ArgTypes> identity<R(ArgTypes...)> f5() {}
Douglas Gregor255c2692011-01-13 17:44:36 +000055// CHECK: define weak_odr void @_Z2f5IiJifdEE8identityIFT_DpT0_EEv
Douglas Gregor4fc48662011-01-13 16:39:34 +000056template identity<int(int, float, double)> f5();
57
58// Mangling of non-type template argument expansions
59template<int ...Values> int_tuple<Values...> f6() {}
60// CHECK: define weak_odr void @_Z2f6IJLi1ELi2ELi3EEE9int_tupleIJXspT_EEEv
61template int_tuple<1, 2, 3> f6();
62
63// Mangling of template template argument expansions
64template<template<typename> class ...Templates>
65template_tuple<Templates...> f7() {}
66// CHECK: define weak_odr void @_Z2f7IJ8identity13add_referenceEE14template_tupleIJDpT_EEv
67template template_tuple<identity, add_reference> f7();