diff options
Diffstat (limited to 'clang/test/CXX')
-rw-r--r-- | clang/test/CXX/class.access/class.access.dcl/p1.cpp | 205 | ||||
-rw-r--r-- | clang/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp | 76 | ||||
-rw-r--r-- | clang/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp | 14 | ||||
-rw-r--r-- | clang/test/CXX/temp/temp.spec/temp.explicit/p2.cpp | 17 | ||||
-rw-r--r-- | clang/test/CXX/temp/temp.spec/temp.explicit/p5.cpp | 9 |
5 files changed, 272 insertions, 49 deletions
diff --git a/clang/test/CXX/class.access/class.access.dcl/p1.cpp b/clang/test/CXX/class.access/class.access.dcl/p1.cpp index aab5fff5ea3..118ab9e52d0 100644 --- a/clang/test/CXX/class.access/class.access.dcl/p1.cpp +++ b/clang/test/CXX/class.access/class.access.dcl/p1.cpp @@ -1,4 +1,6 @@ // 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 is just the test for [namespace.udecl]p4 with 'using' // uniformly stripped out. @@ -24,10 +26,33 @@ namespace test0 { } class Test0 { - NonClass::type; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}} - NonClass::hiding; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}} - NonClass::union_member; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}} - NonClass::enumerator; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}} + NonClass::type; // expected-error {{not a class}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + NonClass::hiding; // expected-error {{not a class}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + NonClass::union_member; // expected-error {{not a class}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + NonClass::enumerator; // expected-error {{not a class}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif }; } @@ -43,11 +68,39 @@ namespace test1 { }; struct B : A { - A::type; // expected-warning {{access declarations are deprecated}} - A::hiding; // expected-warning {{access declarations are deprecated}} - A::union_member; // expected-warning {{access declarations are deprecated}} - A::enumerator; // expected-warning {{access declarations are deprecated}} - A::tagname; // expected-warning {{access declarations are deprecated}} + A::type; +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + A::hiding; +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + A::union_member; +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + A::enumerator; +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + A::tagname; +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif void test0() { type t = 0; @@ -86,11 +139,40 @@ namespace test2 { }; template <class T> struct B : A { - A::type; // expected-warning {{access declarations are deprecated}} - A::hiding; // expected-warning {{access declarations are deprecated}} - A::union_member; // expected-warning {{access declarations are deprecated}} - A::enumerator; // expected-warning {{access declarations are deprecated}} - A::tagname; // expected-warning {{access declarations are deprecated}} + A::type; +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + A::hiding; +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + A::union_member; +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + A::enumerator; +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + A::tagname; +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif void test0() { type t = 0; @@ -131,11 +213,40 @@ namespace test3 { }; template <class T> struct B : A<T> { - A<T>::type; // expected-error {{dependent using declaration resolved to type without 'typename'}} // expected-warning {{access declarations are deprecated}} - A<T>::hiding; // expected-warning {{access declarations are deprecated}} - A<T>::union_member; // expected-warning {{access declarations are deprecated}} - A<T>::enumerator; // expected-warning {{access declarations are deprecated}} - A<T>::tagname; // expected-error {{dependent using declaration resolved to type without 'typename'}} // expected-warning {{access declarations are deprecated}} + A<T>::type; // expected-error {{dependent using declaration resolved to type without 'typename'}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + A<T>::hiding; +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + A<T>::union_member; +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + A<T>::enumerator; +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + A<T>::tagname; // expected-error {{dependent using declaration resolved to type without 'typename'}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif // FIXME: re-enable these when the various bugs involving tags are fixed #if 0 @@ -186,14 +297,54 @@ namespace test4 { // We should be able to diagnose these without instantiation. template <class T> struct C : Base { - InnerNS::foo; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}} - Base::bar; // expected-error {{no member named 'bar'}} expected-warning {{access declarations are deprecated}} - Unrelated::foo; // expected-error {{not a base class}} expected-warning {{access declarations are deprecated}} - C::foo; // legal in C++03 // expected-warning {{access declarations are deprecated}} - Subclass::foo; // legal in C++03 // expected-warning {{access declarations are deprecated}} - - int bar(); //expected-note {{target of using declaration}} - C::bar; // expected-error {{refers to its own class}} expected-warning {{access declarations are deprecated}} + InnerNS::foo; // expected-error {{not a class}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + Base::bar; // expected-error {{no member named 'bar'}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + Unrelated::foo; // expected-error {{not a base class}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + + C::foo; // legal in C++03 +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} + // expected-error@-5 {{using declaration refers to its own class}} +#endif + + Subclass::foo; // legal in C++03 +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} + // expected-error@-5 {{using declaration refers into 'Subclass::', which is not a base class of 'C'}} +#endif + + int bar(); +#if __cplusplus <= 199711L + //expected-note@-2 {{target of using declaration}} +#endif + C::bar; +#if __cplusplus <= 199711L + // expected-warning@-2 {{access declarations are deprecated; use using declarations instead}} +#else + // expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}} +#endif + // expected-error@-6 {{using declaration refers to its own class}} }; } 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<> 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 c8b7def5a44..d82691c7c86 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 @@ -1,14 +1,20 @@ // 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 namespace N { - template<class T> class X; // expected-note {{'N::X' declared here}} \ - // expected-note {{explicitly specialized declaration is here}} + 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'?}} \ - // expected-warning {{first declaration of class template specialization of 'X' outside namespace 'N' is a C++11 extension}} +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 { diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p2.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p2.cpp index 1dfcf0ce2d2..027022176f8 100644 --- a/clang/test/CXX/temp/temp.spec/temp.explicit/p2.cpp +++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p2.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -pedantic -Wc++11-compat %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++98 -Wc++11-compat %s +// RUN: %clang_cc1 -fsyntax-only -verify -pedantic -std=c++11 %s // Example from the standard template<class T> class Array { void mf() { } }; @@ -39,5 +41,16 @@ namespace N { } using namespace N; -template struct X1<int>; // expected-warning{{must occur in}} -template void f1(int); // expected-warning{{must occur in}} +template struct X1<int>; +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'N::X1' must occur in namespace 'N'}} +#else +// expected-error@-4 {{explicit instantiation of 'N::X1' must occur in namespace 'N'}} +#endif + +template void f1(int); +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'N::f1' must occur in namespace 'N'}} +#else +// expected-error@-4 {{explicit instantiation of 'N::f1' must occur in namespace 'N'}} +#endif diff --git a/clang/test/CXX/temp/temp.spec/temp.explicit/p5.cpp b/clang/test/CXX/temp/temp.spec/temp.explicit/p5.cpp index 8422c519a76..ca1f9a391ed 100644 --- a/clang/test/CXX/temp/temp.spec/temp.explicit/p5.cpp +++ b/clang/test/CXX/temp/temp.spec/temp.explicit/p5.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -Wc++11-compat %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s namespace N { template<class T> class Y { // expected-note{{explicit instantiation refers here}} @@ -11,7 +13,12 @@ template class Z<int>; // expected-error{{explicit instantiation of non-template // FIXME: This example from the standard is wrong; note posted to CWG reflector // on 10/27/2009 using N::Y; -template class Y<int>; // expected-warning{{must occur in}} +template class Y<int>; +#if __cplusplus <= 199711L +// expected-warning@-2 {{explicit instantiation of 'N::Y' must occur in namespace 'N'}} +#else +// expected-error@-4 {{explicit instantiation of 'N::Y' must occur in namespace 'N'}} +#endif template class N::Y<char*>; template void N::Y<double>::mf(); |