summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaTemplate/temp_class_spec.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-06-11 18:10:32 +0000
committerDouglas Gregor <dgregor@apple.com>2009-06-11 18:10:32 +0000
commit74eba0b6798cc9d5b1052cae46a9e067e7292cac (patch)
tree2e6274bd919c197aaf30a447d574a0500742fa2d /clang/test/SemaTemplate/temp_class_spec.cpp
parent61797e329101dbbe1230a9b094f8cf71a770bf33 (diff)
downloadbcm5719-llvm-74eba0b6798cc9d5b1052cae46a9e067e7292cac.tar.gz
bcm5719-llvm-74eba0b6798cc9d5b1052cae46a9e067e7292cac.zip
Once we have deduced the template arguments of a class template
partial specialization, substitute those template arguments back into the template arguments of the class template partial specialization to see if the results still match the original template arguments. This code is more general than it needs to be, since we don't yet diagnose C++ [temp.class.spec]p9. However, it's likely to be needed for function templates. llvm-svn: 73196
Diffstat (limited to 'clang/test/SemaTemplate/temp_class_spec.cpp')
-rw-r--r--clang/test/SemaTemplate/temp_class_spec.cpp55
1 files changed, 51 insertions, 4 deletions
diff --git a/clang/test/SemaTemplate/temp_class_spec.cpp b/clang/test/SemaTemplate/temp_class_spec.cpp
index c02ce9b728d..0d83a9bcc3a 100644
--- a/clang/test/SemaTemplate/temp_class_spec.cpp
+++ b/clang/test/SemaTemplate/temp_class_spec.cpp
@@ -224,6 +224,8 @@ int is_member_function_pointer3[
int is_member_function_pointer4[
is_member_function_pointer<int (X::*)(float) const>::value? 1 : -1];
+// Test substitution of non-dependent arguments back into the template
+// argument list of the class template partial specialization.
template<typename T, typename ValueType = T>
struct is_nested_value_type_identity {
static const bool value = false;
@@ -245,11 +247,56 @@ struct HasIdentityValueType {
struct NoValueType { };
-// FIXME: Need substitution into the template arguments of the partial spec
-//int is_nested_value_type_identity0[
-// is_nested_value_type_identity<HasValueType<int> >::value? -1 : 1];
+int is_nested_value_type_identity0[
+ is_nested_value_type_identity<HasValueType<int> >::value? -1 : 1];
int is_nested_value_type_identity1[
is_nested_value_type_identity<HasIdentityValueType>::value? 1 : -1];
// FIXME: Enable when we have SFINAE support
-//int is_nested_value_type_identity0[
+//int is_nested_value_type_identity2[
// is_nested_value_type_identity<NoValueType>::value? -1 : 1];
+
+// FIXME: The tests that follow are stress-tests for the substitution
+// of deduced template arguments into the template argument list of a
+// partial specialization. I believe that we'll need this code for
+// substitution into function templates, but note that the examples
+// below are ill-formed and should eventually be removed.
+template<typename T, int N>
+struct is_sizeof_T {
+ static const bool value = false;
+};
+
+template<typename T>
+struct is_sizeof_T<T, sizeof(T)> {
+ static const bool value = true;
+};
+
+int is_sizeof_T0[is_sizeof_T<int, sizeof(int)>::value? 1 : -1];
+int is_sizeof_T1[is_sizeof_T<int, sizeof(char)>::value? -1 : 1];
+
+template<typename T>
+struct HasStaticOfT {
+ static T value;
+ static T other_value;
+};
+
+struct DerivedStaticOfInt : HasStaticOfT<int> { };
+
+template<typename X, typename T, T *Ptr>
+struct is_static_int_val {
+ static const bool value = false;
+};
+
+template<typename X, typename T>
+struct is_static_int_val<X, T, &X::value> {
+ static const bool value = true;
+};
+
+int is_static_int_val0[
+ is_static_int_val<HasStaticOfT<int>, int,
+ &HasStaticOfT<int>::value>::value ? 1 : -1];
+int is_static_int_val1[
+ is_static_int_val<HasStaticOfT<int>, int,
+ &HasStaticOfT<int>::other_value>::value ? -1 : 1];
+int is_static_int_val2[
+ is_static_int_val<DerivedStaticOfInt, int,
+ &HasStaticOfT<int>::value>::value ? 1 : -1];
OpenPOWER on IntegriCloud