aboutsummaryrefslogtreecommitdiff
path: root/test/SemaTemplate/class-template-spec.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaTemplate/class-template-spec.cpp')
-rw-r--r--test/SemaTemplate/class-template-spec.cpp44
1 files changed, 33 insertions, 11 deletions
diff --git a/test/SemaTemplate/class-template-spec.cpp b/test/SemaTemplate/class-template-spec.cpp
index 4de220a77c..4ae1b9bdc9 100644
--- a/test/SemaTemplate/class-template-spec.cpp
+++ b/test/SemaTemplate/class-template-spec.cpp
@@ -1,13 +1,13 @@
// RUN: clang -fsyntax-only -verify %s
-template<typename T, typename U = int> class A;
+template<typename T, typename U = int> struct A; // expected-note{{template is declared here}}
-template<> class A<double, double>; // expected-note{{forward declaration}}
+template<> struct A<double, double>; // expected-note{{forward declaration}}
-template<> class A<float, float> { // expected-note{{previous definition}}
+template<> struct A<float, float> { // expected-note{{previous definition}}
int x;
};
-template<> class A<float> { // expected-note{{previous definition}}
+template<> struct A<float> { // expected-note{{previous definition}}
int y;
};
@@ -24,16 +24,16 @@ int test_incomplete_specs(A<double, double> *a1,
typedef float FLOAT;
-template<> class A<float, FLOAT>;
+template<> struct A<float, FLOAT>;
-template<> class A<FLOAT, float> { }; // expected-error{{redefinition}}
+template<> struct A<FLOAT, float> { }; // expected-error{{redefinition}}
-template<> class A<float, int> { }; // expected-error{{redefinition}}
+template<> struct A<float, int> { }; // expected-error{{redefinition}}
-template<typename T, typename U = int> class X;
+template<typename T, typename U = int> struct X;
-template <> class X<int, int> { int foo(); }; // #1
-template <> class X<float> { int bar(); }; // #2
+template <> struct X<int, int> { int foo(); }; // #1
+template <> struct X<float> { int bar(); }; // #2
typedef int int_type;
void testme(X<int_type> *x1, X<float, int> *x2) {
@@ -42,4 +42,26 @@ void testme(X<int_type> *x1, X<float, int> *x2) {
}
// Diagnose specializations in a different namespace
-class A<double> { };
+struct A<double> { }; // expected-error{{template specialization requires 'template<>'}}
+
+template<typename T> // expected-error{{class template partial specialization is not yet supported}}
+struct A<T*> { };
+
+template<> struct ::A<double>;
+
+namespace N {
+ template<typename T> struct B; // expected-note 2{{template is declared here}}
+
+ template<> struct ::N::B<short>; // okay
+ template<> struct ::N::B<int>; // okay
+}
+
+template<> struct N::B<int> { }; // okay
+
+template<> struct N::B<float> { }; // expected-error{{class template specialization of 'B' not in namespace 'N'}}
+
+namespace M {
+ template<> struct ::N::B<short> { }; // expected-error{{class template specialization of 'B' not in a namespace enclosing 'N'}}
+
+ template<> struct ::A<long double>; // expected-error{{class template specialization of 'A' must occur in the global scope}}
+}