summaryrefslogtreecommitdiff
path: root/clang/test/CXX/temp/temp.decls/temp.class.spec
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CXX/temp/temp.decls/temp.class.spec')
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp76
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp8
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp13
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class.spec/p9.cpp26
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp48
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1-neg.cpp25
-rw-r--r--clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1.cpp25
7 files changed, 221 insertions, 0 deletions
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
new file mode 100644
index 0000000..d0fc797
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
@@ -0,0 +1,76 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// Test class template partial specializations of member templates.
+template<typename T>
+struct X0 {
+ template<typename U> struct Inner0 {
+ static const unsigned value = 0;
+ };
+
+ template<typename U> struct Inner0<U*> {
+ static const unsigned value = 1;
+ };
+};
+
+template<typename T> template<typename U>
+struct X0<T>::Inner0<const U*> {
+ static const unsigned value = 2;
+};
+
+int array0[X0<int>::Inner0<int>::value == 0? 1 : -1];
+int array1[X0<int>::Inner0<int*>::value == 1? 1 : -1];
+int array2[X0<int>::Inner0<const int*>::value == 2? 1 : -1];
+
+// Make sure we can provide out-of-line class template partial specializations
+// for member templates (and instantiate them).
+template<class T> struct A {
+ struct C {
+ template<class T2> struct B;
+ };
+};
+
+// partial specialization of A<T>::C::B<T2>
+template<class T> template<class T2> struct A<T>::C::B<T2*> { };
+
+A<short>::C::B<int*> absip;
+
+// Check for conflicts during template instantiation.
+template<typename T, typename U>
+struct Outer {
+ template<typename X, typename Y> struct Inner;
+ template<typename Y> struct Inner<T, Y> {}; // expected-note{{previous}}
+ template<typename Y> struct Inner<U, Y> {}; // expected-error{{cannot be redeclared}}
+};
+
+Outer<int, int> outer; // expected-note{{instantiation}}
+
+// Test specialization of class template partial specialization members.
+template<> template<typename Z>
+struct X0<float>::Inner0<Z*> {
+ static const unsigned value = 3;
+};
+
+int array3[X0<float>::Inner0<int>::value == 0? 1 : -1];
+int array4[X0<float>::Inner0<int*>::value == 3? 1 : -1];
+int array5[X0<float>::Inner0<const int*>::value == 2? 1 : -1];
+
+namespace rdar8651930 {
+ template<typename OuterT>
+ struct Outer {
+ template<typename T, typename U>
+ struct Inner;
+
+ template<typename T>
+ struct Inner<T, T> {
+ static const bool value = true;
+ };
+
+ template<typename T, typename U>
+ struct Inner {
+ static const bool value = false;
+ };
+ };
+
+ int array0[Outer<int>::Inner<int, int>::value? 1 : -1];
+ int array1[Outer<int>::Inner<int, float>::value? -1 : 1];
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp
new file mode 100644
index 0000000..aa1e2d4
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/p8-0x.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+template<int ...Values> struct X1;
+
+template<int ...Values>
+struct X1<0, Values+1 ...>; // expected-error{{non-type template argument depends on a template parameter of the partial specialization}}
+
+
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp
new file mode 100644
index 0000000..b754368
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/p9-0x.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+// -- The argument list of the specialization shall not be identical
+// to the implicit argument list of the primary template.
+
+template<typename T, typename ...Types>
+struct X1;
+
+template<typename T, typename ...Types>
+struct X1<T, Types...> // expected-error{{class template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}}
+{ };
+
+
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/p9.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/p9.cpp
new file mode 100644
index 0000000..2a3e914
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/p9.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// PR8905
+template<char C1, char C2>
+struct X {
+ static const bool value = 0;
+};
+
+template<int C1>
+struct X<C1, C1> {
+ static const bool value = 1;
+};
+
+int check0[X<1, 2>::value == 0? 1 : -1];
+int check1[X<1, 1>::value == 1? 1 : -1];
+
+template<int, int, int> struct int_values {
+ static const unsigned value = 0;
+};
+
+template<unsigned char C1, unsigned char C3>
+struct int_values<C1, 12, C3> {
+ static const unsigned value = 1;
+};
+
+int check2[int_values<256, 12, 3>::value == 0? 1 : -1];
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp
new file mode 100644
index 0000000..97457ea
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.order/p2.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<int I, int J, class T> struct X {
+ static const int value = 0;
+};
+
+template<int I, int J> struct X<I, J, int> {
+ static const int value = 1;
+};
+
+template<int I> struct X<I, I, int> {
+ static const int value = 2;
+};
+
+int array0[X<0, 0, float>::value == 0? 1 : -1];
+int array1[X<0, 1, int>::value == 1? 1 : -1];
+int array2[X<0, 0, int>::value == 2? 1 : -1];
+
+namespace DependentSubstPartialOrdering {
+ template<typename T, typename U = void, typename V = void>
+ struct X {
+ static const unsigned value = 1;
+ };
+
+ template<typename T, typename U>
+ struct X<T, U, typename T::is_b> {
+ static const unsigned value = 2;
+ };
+
+ template<typename T>
+ struct X<T, typename T::is_a, typename T::is_b> {
+ static const unsigned value = 3;
+ };
+
+ struct X1 { };
+
+ struct X2 {
+ typedef void is_b;
+ };
+
+ struct X3 {
+ typedef void is_a;
+ typedef void is_b;
+ };
+
+ int check_X1[X<X1, void, void>::value == 1? 1 : -1];
+ int check_X2[X<X2, void, void>::value == 2? 1 : -1];
+ int check_X3[X<X3, void, void>::value == 3? 1 : -1];
+}
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1-neg.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1-neg.cpp
new file mode 100644
index 0000000..59253db
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1-neg.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T, int N>
+struct A;
+
+template<typename T> // expected-note{{previous template declaration}}
+struct A<T*, 2> {
+ void f0();
+ void f1();
+ void f2();
+};
+
+template<>
+struct A<int, 1> {
+ void g0();
+};
+
+// FIXME: We should probably give more precise diagnostics here, but the
+// diagnostics we give aren't terrible.
+// FIXME: why not point to the first parameter that's "too many"?
+template<typename T, int N> // expected-error{{too many template parameters}}
+void A<T*, 2>::f0() { }
+
+template<typename T, int N>
+void A<T, N>::f1() { } // expected-error{{out-of-line definition}}
diff --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1.cpp b/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1.cpp
new file mode 100644
index 0000000..87e21e4
--- /dev/null
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/temp.class.spec.mfunc/p1.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+template<typename T, int N>
+struct A;
+
+template<typename T>
+struct A<T*, 2> {
+ A(T);
+ ~A();
+
+ void f(T*);
+
+ operator T*();
+
+ static T value;
+};
+
+template<class X> void A<X*, 2>::f(X*) { }
+
+template<class X> X A<X*, 2>::value;
+
+template<class X> A<X*, 2>::A(X) { value = 0; }
+
+template<class X> A<X*, 2>::~A() { }
+
+template<class X> A<X*, 2>::operator X*() { return 0; }