summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-12-24 00:35:52 +0000
committerDouglas Gregor <dgregor@apple.com>2010-12-24 00:35:52 +0000
commitb4d271ef46bde4815c3ca3363779645ce3513811 (patch)
tree38ef34faf1e2a8aa1c8940347fe40e01b503a7cc /clang/test
parent0da4a99ad36c11ee18d36c353eb4256945dfdf7b (diff)
downloadbcm5719-llvm-b4d271ef46bde4815c3ca3363779645ce3513811.tar.gz
bcm5719-llvm-b4d271ef46bde4815c3ca3363779645ce3513811.zip
Fix a thinko in a helper routine for template argument deduction that
caused an assertion when dealing with non-type template parameter packs. Add some tests for deduction and instantiation of non-type template parameter packs. llvm-svn: 122534
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp32
1 files changed, 31 insertions, 1 deletions
diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp
index ebfcd3808e6..508722437c3 100644
--- a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp
+++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.type/p9-0x.cpp
@@ -1,6 +1,17 @@
// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s
template<typename ...Types> struct tuple;
+template<unsigned> struct unsigned_c;
+
+template<typename T, typename U>
+struct is_same {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_same<T, T> {
+ static const bool value = true;
+};
namespace PackExpansionNotAtEnd {
template<typename T, typename U>
@@ -19,7 +30,26 @@ namespace PackExpansionNotAtEnd {
template<typename ... Types> struct UselessPartialSpec;
- template<typename ... Types, // expected-note{{non-deducible template parameter 'Types'}}
+ template<typename ... Types, // expected-note{{non-deducible template parameter 'Types'}}
typename Tail> // expected-note{{non-deducible template parameter 'Tail'}}
struct UselessPartialSpec<Types..., Tail>; // expected-warning{{class template partial specialization contains template parameters that can not be deduced; this partial specialization will never be used}}
}
+
+namespace DeduceNonTypeTemplateArgsInArray {
+ template<typename ...ArrayTypes>
+ struct split_arrays;
+
+ template<typename ...ElementTypes, unsigned ...Bounds>
+ struct split_arrays<ElementTypes[Bounds]...> {
+ typedef tuple<ElementTypes...> element_types;
+
+ // FIXME: Would like to have unsigned_tuple<Bounds...> here.
+ typedef tuple<unsigned_c<Bounds>...> bounds_types;
+ };
+
+ int check1[is_same<split_arrays<int[1], float[2], double[3]>::element_types,
+ tuple<int, float, double>>::value? 1 : -1];
+ int check2[is_same<split_arrays<int[1], float[2], double[3]>::bounds_types,
+ tuple<unsigned_c<1>, unsigned_c<2>, unsigned_c<3>>
+ >::value? 1 : -1];
+}
OpenPOWER on IntegriCloud