diff options
Diffstat (limited to 'clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp')
-rw-r--r-- | clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp | 76 |
1 files changed, 61 insertions, 15 deletions
diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp index 4fbc45a7d7d..21399b62046 100644 --- a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp +++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp @@ -1,4 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s + // This test creates cases where implicit instantiations of various entities // would cause a diagnostic, but provides expliict specializations for those @@ -16,7 +19,10 @@ struct NonDefaultConstructible { // -- function template namespace N0 { - template<typename T> void f0(T) { // expected-note{{here}} + template<typename T> void f0(T) { +#if __cplusplus <= 199711L + // expected-note@-2 {{explicitly specialized declaration is here}} +#endif T t; } @@ -36,7 +42,11 @@ namespace N1 { template<> void N0::f0(long) { } // expected-error{{does not enclose namespace}} } -template<> void N0::f0(double); // expected-warning{{C++11 extension}} +template<> void N0::f0(double); +#if __cplusplus <= 199711L +// expected-warning@-2 {{first declaration of function template specialization of 'f0' outside namespace 'N0' is a C++11 extension}} +#endif + template<> void N0::f0(double) { } struct X1 { @@ -49,21 +59,39 @@ struct X1 { namespace N0 { template<typename T> -struct X0 { // expected-note 2{{here}} - static T member; // expected-note{{here}} +struct X0 { // expected-note {{explicitly specialized declaration is here}} +#if __cplusplus <= 199711L +// expected-note@-2 {{explicitly specialized declaration is here}} +#endif + static T member; +#if __cplusplus <= 199711L + // expected-note@-2 {{explicitly specialized declaration is here}} +#endif - void f1(T t) { // expected-note{{explicitly specialized declaration is here}} + void f1(T t) { +#if __cplusplus <= 199711L + // expected-note@-2 {{explicitly specialized declaration is here}} +#endif t = 17; } - struct Inner : public T { }; // expected-note 3{{here}} + struct Inner : public T { }; // expected-note 2{{explicitly specialized declaration is here}} +#if __cplusplus <= 199711L + // expected-note@-2 {{explicitly specialized declaration is here}} +#endif template<typename U> - struct InnerTemplate : public T { }; // expected-note 2{{explicitly specialized}} \ - // expected-error{{base specifier}} + struct InnerTemplate : public T { }; // expected-note {{explicitly specialized declaration is here}} +#if __cplusplus <= 199711L + // expected-note@-2 {{explicitly specialized declaration is here}} +#endif + // expected-error@-4 {{base specifier must name a class}} template<typename U> - void ft1(T t, U u); // expected-note{{explicitly specialized}} + void ft1(T t, U u); +#if __cplusplus <= 199711L + // expected-note@-2 {{explicitly specialized declaration is here}} +#endif }; } @@ -76,7 +104,10 @@ void N0::X0<T>::ft1(T t, U u) { template<typename T> T N0::X0<T>::member; -template<> struct N0::X0<void> { }; // expected-warning{{C++11 extension}} +template<> struct N0::X0<void> { }; +#if __cplusplus <= 199711L +// expected-warning@-2 {{first declaration of class template specialization of 'X0' outside namespace 'N0' is a C++11 extension}} +#endif N0::X0<void> test_X0; namespace N1 { @@ -92,7 +123,10 @@ template<> struct N0::X0<volatile void> { }; // -- member function of a class template -template<> void N0::X0<void*>::f1(void *) { } // expected-warning{{member function specialization}} +template<> void N0::X0<void*>::f1(void *) { } +#if __cplusplus <= 199711L +// expected-warning@-2 {{first declaration of member function specialization of 'f1' outside namespace 'N0' is a C++11 extension}} +#endif void test_spec(N0::X0<void*> xvp, void *vp) { xvp.f1(vp); @@ -125,7 +159,10 @@ NonDefaultConstructible &get_static_member() { return N0::X0<NonDefaultConstructible>::member; } -template<> int N0::X0<int>::member; // expected-warning{{C++11 extension}} +template<> int N0::X0<int>::member; +#if __cplusplus <= 199711L +// expected-warning@-2 {{first declaration of static data member specialization of 'member' outside namespace 'N0' is a C++11 extension}} +#endif template<> float N0::X0<float>::member = 3.14f; @@ -153,7 +190,10 @@ namespace N0 { } template<> -struct N0::X0<long>::Inner { }; // expected-warning{{C++11 extension}} +struct N0::X0<long>::Inner { }; +#if __cplusplus <= 199711L +// expected-warning@-2 {{first declaration of member class specialization of 'Inner' outside namespace 'N0' is a C++11 extension}} +#endif template<> struct N0::X0<float>::Inner { }; @@ -192,7 +232,10 @@ template<> template<> struct N0::X0<int>::InnerTemplate<long> { }; // okay template<> template<> -struct N0::X0<int>::InnerTemplate<float> { }; // expected-warning{{class template specialization}} +struct N0::X0<int>::InnerTemplate<float> { }; +#if __cplusplus <= 199711L +// expected-warning@-2 {{first declaration of class template specialization of 'InnerTemplate' outside namespace 'N0' is a C++11 extension}} +#endif namespace N1 { template<> template<> @@ -224,7 +267,10 @@ template<> template<> void N0::X0<void*>::ft1(void *, unsigned) { } // okay template<> template<> -void N0::X0<void*>::ft1(void *, float) { } // expected-warning{{function template specialization}} +void N0::X0<void*>::ft1(void *, float) { } +#if __cplusplus <= 199711L +// expected-warning@-2 {{first declaration of function template specialization of 'ft1' outside namespace 'N0' is a C++11 extension}} +#endif namespace N1 { template<> template<> |