2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
2015-11-12 03:34:47 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
|
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
|
2009-06-13 03:43:02 +08:00
|
|
|
template<typename T> struct vector;
|
|
|
|
|
2009-06-13 06:21:45 +08:00
|
|
|
// C++ [temp.class.spec]p6:
|
|
|
|
namespace N {
|
|
|
|
namespace M {
|
2015-11-12 03:34:47 +08:00
|
|
|
template<typename T> struct A;
|
|
|
|
#if __cplusplus <= 199711L // C++03 or earlier modes
|
|
|
|
// expected-note@-2{{explicitly specialized declaration is here}}
|
|
|
|
#endif
|
2009-06-13 06:21:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T>
|
2015-11-12 03:34:47 +08:00
|
|
|
struct N::M::A<T*> { };
|
|
|
|
#if __cplusplus <= 199711L
|
|
|
|
// expected-warning@-2{{first declaration of class template partial specialization of 'A' outside namespace 'M' is a C++11 extension}}
|
|
|
|
#endif
|
2009-06-13 05:21:02 +08:00
|
|
|
|
2009-06-13 06:21:45 +08:00
|
|
|
// C++ [temp.class.spec]p9
|
2009-06-13 05:21:02 +08:00
|
|
|
// bullet 1
|
|
|
|
template <int I, int J> struct A {};
|
|
|
|
template <int I> struct A<I+5, I*2> {}; // expected-error{{depends on}}
|
|
|
|
template <int I, int J> struct B {};
|
|
|
|
template <int I> struct B<I, I> {}; //OK
|
|
|
|
|
|
|
|
// bullet 2
|
|
|
|
template <class T, T t> struct C {}; // expected-note{{declared here}}
|
|
|
|
template <class T> struct C<T, 1>; // expected-error{{specializes}}
|
|
|
|
template <class T, T* t> struct C<T*, t>; // okay
|
|
|
|
|
|
|
|
template< int X, int (*array_ptr)[X] > class A2 {}; // expected-note{{here}}
|
|
|
|
int array[5];
|
2009-10-07 08:13:32 +08:00
|
|
|
template< int X > class A2<X, &array> { }; // expected-error{{specializes}}
|
2009-06-13 05:21:02 +08:00
|
|
|
|
2009-06-13 03:43:02 +08:00
|
|
|
template<typename T, int N, template<typename X> class TT>
|
|
|
|
struct Test0;
|
|
|
|
|
2009-06-13 06:08:06 +08:00
|
|
|
// bullet 3
|
|
|
|
template<typename T, int N, template<typename X> class TT>
|
|
|
|
struct Test0<T, N, TT>; // expected-error{{does not specialize}}
|
|
|
|
|
|
|
|
// C++ [temp.class.spec]p10
|
2009-06-13 03:43:02 +08:00
|
|
|
template<typename T = int, // expected-error{{default template argument}}
|
|
|
|
int N = 17, // expected-error{{default template argument}}
|
|
|
|
template<typename X> class TT = ::vector> // expected-error{{default template argument}}
|
|
|
|
struct Test0<T*, N, TT> { };
|
2009-06-13 08:26:55 +08:00
|
|
|
|
|
|
|
template<typename T> struct Test1;
|
|
|
|
template<typename T, typename U> // expected-note{{non-deducible}}
|
|
|
|
struct Test1<T*> { }; // expected-warning{{never be used}}
|