diff options
Diffstat (limited to 'clang/test/CXX/temp')
5 files changed, 21 insertions, 76 deletions
diff --git a/clang/test/CXX/temp/temp.deduct.guide/p1.cpp b/clang/test/CXX/temp/temp.deduct.guide/p1.cpp index c0a2ba1129e..8bb9da8a972 100644 --- a/clang/test/CXX/temp/temp.deduct.guide/p1.cpp +++ b/clang/test/CXX/temp/temp.deduct.guide/p1.cpp @@ -101,7 +101,7 @@ namespace ExplicitInst { struct X { template<typename T> struct C {}; template<typename T> C(T) -> C<T>; - template<> C(int) -> C<int>; // expected-error {{explicit specialization of '<deduction guide for C>' in class scope}} + template<> C(int) -> C<int>; // expected-error {{deduction guide cannot be explicitly specialized}} extern template C(float) -> C<float>; // expected-error {{expected member name or ';'}} template C(char) -> C<char>; // expected-error {{expected '<' after 'template'}} }; diff --git a/clang/test/CXX/temp/temp.spec/cxx1y-variable-template-no-body.cpp b/clang/test/CXX/temp/temp.spec/cxx1y-variable-template-no-body.cpp index 425d527e521..741ebc5de41 100644 --- a/clang/test/CXX/temp/temp.spec/cxx1y-variable-template-no-body.cpp +++ b/clang/test/CXX/temp/temp.spec/cxx1y-variable-template-no-body.cpp @@ -28,10 +28,8 @@ T pi1 = T(3.1415926535897932385); // expected-note 0-2 {{here}} // Should recover as if specialization template float pi1<float> = 1.0; // expected-error {{explicit template instantiation cannot have a definition; if this definition is meant to be an explicit specialization, add '<>' after the 'template' keyword}} -#ifndef FIXING namespace expected_global { - template<> double pi1<double> = 1.5; // expected-error {{variable template specialization of 'pi1' must originally be declared in the global scope}} - template int pi1<int> = 10; // expected-error {{explicit template instantiation cannot have a definition; if this definition is meant to be an explicit specialization, add '<>' after the 'template' keyword}} \ - expected-error {{variable template specialization of 'pi1' must originally be declared in the global scope}} -} +#ifndef FIXING + template int pi1<int> = 10; // expected-error {{explicit template instantiation cannot have a definition; if this definition is meant to be an explicit specialization, add '<>' after the 'template' keyword}} expected-error {{must occur at global scope}} #endif +} diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp index d0e24f54772..c29646dd945 100644 --- a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp +++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p2-0x.cpp @@ -10,9 +10,6 @@ struct NonDefaultConstructible { NonDefaultConstructible(int); }; -// FIXME: The "must originally be declared in namespace" diagnostics throughout -// this file are wrong. - // C++ [temp.expl.spec]p1: // An explicit specialization of any of the following: @@ -43,7 +40,7 @@ template<> void N0::f0(double) { } struct X1 { template<typename T> void f(T); - template<> void f(int); // expected-error{{in class scope}} + template<> void f(int); // OK (DR727) }; // -- class template @@ -94,7 +91,7 @@ template<> struct N0::X0<volatile void> { // -- variable template [C++1y] namespace N0 { -template<typename T> int v0; // expected-note +{{here}} +template<typename T> int v0; // expected-note 4{{explicitly specialized declaration is here}} template<> extern int v0<char[1]>; template<> extern int v0<char[2]>; template<> extern int v0<char[5]>; @@ -102,32 +99,32 @@ template<> extern int v0<char[6]>; } using N0::v0; -template<typename T> int v1; // expected-note +{{here}} +template<typename T> int v1; // expected-note 4{{explicitly specialized declaration is here}} template<> extern int v1<char[3]>; template<> extern int v1<char[4]>; template<> extern int v1<char[7]>; template<> extern int v1<char[8]>; template<> int N0::v0<int[1]>; -template<> int v0<int[2]>; // FIXME: ill-formed +template<> int v0<int[2]>; template<> int ::v1<int[3]>; // expected-warning {{extra qualification}} template<> int v1<int[4]>; template<> int N0::v0<char[1]>; -template<> int v0<char[2]>; // FIXME: ill-formed +template<> int v0<char[2]>; template<> int ::v1<char[3]>; // expected-warning {{extra qualification}} template<> int v1<char[4]>; namespace N1 { -template<> int N0::v0<int[5]>; // expected-error {{must originally be declared in namespace 'N0'}} expected-error {{does not enclose namespace}} -template<> int v0<int[6]>; // expected-error {{must originally be declared in namespace 'N0'}} -template<> int ::v1<int[7]>; // expected-error {{must originally be declared in the global scope}} expected-error {{cannot name the global scope}} -template<> int v1<int[8]>; // expected-error {{must originally be declared in the global scope}} - -template<> int N0::v0<char[5]>; // expected-error {{does not enclose namespace 'N0'}} -template<> int v0<char[6]>; // FIXME: ill-formed -template<> int ::v1<char[7]>; // expected-error {{cannot name the global scope}} -template<> int v1<char[8]>; // FIXME: ill-formed +template<> int N0::v0<int[5]>; // expected-error {{not in a namespace enclosing 'N0'}} +template<> int v0<int[6]>; // expected-error {{not in a namespace enclosing 'N0'}} +template<> int ::v1<int[7]>; // expected-error {{must occur at global scope}} +template<> int v1<int[8]>; // expected-error {{must occur at global scope}} + +template<> int N0::v0<char[5]>; // expected-error {{not in a namespace enclosing 'N0'}} +template<> int v0<char[6]>; // expected-error {{not in a namespace enclosing 'N0'}} +template<> int ::v1<char[7]>; // expected-error {{must occur at global scope}} +template<> int v1<char[8]>; // expected-error {{must occur at global scope}} } // -- member function of a class template 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 21399b62046..904f950df44 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 @@ -20,9 +20,6 @@ struct NonDefaultConstructible { // -- function template namespace N0 { template<typename T> void f0(T) { -#if __cplusplus <= 199711L - // expected-note@-2 {{explicitly specialized declaration is here}} -#endif T t; } @@ -43,16 +40,13 @@ namespace N1 { } 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 { template<typename T> void f(T); - template<> void f(int); // expected-error{{in class scope}} + template<> void f(int); }; // -- class template @@ -60,38 +54,20 @@ namespace N0 { template<typename T> 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) { -#if __cplusplus <= 199711L - // expected-note@-2 {{explicitly specialized declaration is here}} -#endif t = 17; } 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 {{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}} + // expected-error@-1 {{base specifier must name a class}} template<typename U> void ft1(T t, U u); -#if __cplusplus <= 199711L - // expected-note@-2 {{explicitly specialized declaration is here}} -#endif }; } @@ -105,9 +81,6 @@ void N0::X0<T>::ft1(T t, U u) { template<typename T> T N0::X0<T>::member; 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 { @@ -124,9 +97,6 @@ template<> struct N0::X0<volatile void> { // -- member function of a class template 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); @@ -160,9 +130,6 @@ NonDefaultConstructible &get_static_member() { } 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; @@ -191,9 +158,6 @@ namespace N0 { template<> 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 { }; @@ -233,9 +197,6 @@ struct N0::X0<int>::InnerTemplate<long> { }; // okay template<> template<> 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<> @@ -268,9 +229,6 @@ void N0::X0<void*>::ft1(void *, unsigned) { } // okay template<> template<> 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<> @@ -293,6 +251,6 @@ namespace PR8979 { template<typename T, typename U> void f(Inner<T, U>&); typedef Inner<OtherInner, OtherInner> MyInner; - template<> void f(MyInner&); // expected-error{{cannot specialize a function 'f' within class scope}} + template<> void f(MyInner&); }; } diff --git a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp index d82691c7c86..ca55c54a5e9 100644 --- a/clang/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp +++ b/clang/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp @@ -4,17 +4,9 @@ namespace N { template<class T> class X; // expected-note {{'N::X' declared here}} -#if __cplusplus <= 199711L - // expected-note@-2 {{explicitly specialized declaration is here}} -#endif } -// TODO: Don't add a namespace qualifier to the template if it would trigger -// the warning about the specialization being outside of the namespace. template<> class X<int> { /* ... */ }; // expected-error {{no template named 'X'; did you mean 'N::X'?}} -#if __cplusplus <= 199711L -// expected-warning@-2 {{first declaration of class template specialization of 'X' outside namespace 'N' is a C++11 extension}} -#endif namespace N { |