diff options
Diffstat (limited to 'clang/test/SemaCXX')
-rw-r--r-- | clang/test/SemaCXX/addr-of-overloaded-function.cpp | 7 | ||||
-rw-r--r-- | clang/test/SemaCXX/const-cast.cpp | 13 | ||||
-rw-r--r-- | clang/test/SemaCXX/convert-to-bool.cpp | 18 | ||||
-rw-r--r-- | clang/test/SemaCXX/copy-initialization.cpp | 8 | ||||
-rw-r--r-- | clang/test/SemaCXX/cxx0x-return-init-list.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/decltype-crash.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/gnu-flags.cpp | 26 | ||||
-rw-r--r-- | clang/test/SemaCXX/invalid-member-expr.cpp | 12 | ||||
-rw-r--r-- | clang/test/SemaCXX/member-expr.cpp | 8 | ||||
-rw-r--r-- | clang/test/SemaCXX/member-pointer.cpp | 9 | ||||
-rw-r--r-- | clang/test/SemaCXX/new-array-size-conv.cpp | 13 | ||||
-rw-r--r-- | clang/test/SemaCXX/offsetof.cpp | 2 | ||||
-rw-r--r-- | clang/test/SemaCXX/printf-block.cpp | 10 | ||||
-rw-r--r-- | clang/test/SemaCXX/undefined-internal.cpp | 11 |
14 files changed, 120 insertions, 21 deletions
diff --git a/clang/test/SemaCXX/addr-of-overloaded-function.cpp b/clang/test/SemaCXX/addr-of-overloaded-function.cpp index 09f280bc1db..cca847b4d2c 100644 --- a/clang/test/SemaCXX/addr-of-overloaded-function.cpp +++ b/clang/test/SemaCXX/addr-of-overloaded-function.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 int f(double); // expected-note{{candidate function}} int f(int); // expected-note{{candidate function}} @@ -79,7 +81,10 @@ struct C { void q3(); // expected-note{{possible target for call}} template<typename T1, typename T2> void q4(); // expected-note{{possible target for call}} - template<typename T1 = int> // expected-warning{{default template arguments for a function template are a C++11 extension}} + template<typename T1 = int> +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2{{default template arguments for a function template are a C++11 extension}} +#endif void q5(); // expected-note{{possible target for call}} void h() { diff --git a/clang/test/SemaCXX/const-cast.cpp b/clang/test/SemaCXX/const-cast.cpp index 330e18661b1..87df61cbc7b 100644 --- a/clang/test/SemaCXX/const-cast.cpp +++ b/clang/test/SemaCXX/const-cast.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 struct A {}; @@ -38,8 +40,10 @@ char ***good_const_cast_test(ccvpcvpp var) f *fpp = const_cast<f*>(&fp); int const A::* const A::*icapcap = 0; int A::* A::* iapap = const_cast<int A::* A::*>(icapcap); - (void)const_cast<A&&>(A()); // expected-warning {{C++11}} - + (void)const_cast<A&&>(A()); +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2 {{rvalue references are a C++11 extension}} +#endif return var4; } @@ -61,7 +65,10 @@ short *bad_const_cast_test(char const *volatile *const volatile *var) f fp2 = const_cast<f>(fp1); // expected-error {{const_cast to 'f' (aka 'int (*)(int)'), which is not a reference, pointer-to-object, or pointer-to-data-member}} void (A::*mfn)() = 0; (void)const_cast<void (A::*)()>(mfn); // expected-error-re {{const_cast to 'void (A::*)(){{( __attribute__\(\(thiscall\)\))?}}', which is not a reference, pointer-to-object, or pointer-to-data-member}} - (void)const_cast<int&&>(0); // expected-error {{const_cast from rvalue to reference type 'int &&'}} expected-warning {{C++11}} + (void)const_cast<int&&>(0); // expected-error {{const_cast from rvalue to reference type 'int &&'}} +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2 {{rvalue references are a C++11 extension}} +#endif return **var3; } diff --git a/clang/test/SemaCXX/convert-to-bool.cpp b/clang/test/SemaCXX/convert-to-bool.cpp index b52f11c93d3..117b50899b7 100644 --- a/clang/test/SemaCXX/convert-to-bool.cpp +++ b/clang/test/SemaCXX/convert-to-bool.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 + struct ConvToBool { operator bool() const; }; @@ -8,7 +11,10 @@ struct ConvToInt { }; struct ExplicitConvToBool { - explicit operator bool(); // expected-warning{{explicit conversion functions are a C++11 extension}} + explicit operator bool(); +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2{{explicit conversion functions are a C++11 extension}} +#endif }; void test_conv_to_bool(ConvToBool ctb, ConvToInt cti, ExplicitConvToBool ecb) { @@ -39,7 +45,10 @@ void test_conv_to_bool(ConvToBool ctb, ConvToInt cti, ExplicitConvToBool ecb) { void accepts_bool(bool) { } // expected-note{{candidate function}} struct ExplicitConvToRef { - explicit operator int&(); // expected-warning{{explicit conversion functions are a C++11 extension}} + explicit operator int&(); +#if (__cplusplus <= 199711L) // C++03 or earlier modes + // expected-warning@-2{{explicit conversion functions are a C++11 extension}} +#endif }; void test_explicit_bool(ExplicitConvToBool ecb) { @@ -56,7 +65,10 @@ void test_explicit_conv_to_ref(ExplicitConvToRef ecr) { struct A { }; struct B { }; struct C { - explicit operator A&(); // expected-warning{{explicit conversion functions are a C++11 extension}} + explicit operator A&(); +#if __cplusplus <= 199711L // C++03 or earlier modes +// expected-warning@-2{{explicit conversion functions are a C++11 extension}} +#endif operator B&(); // expected-note{{candidate}} }; diff --git a/clang/test/SemaCXX/copy-initialization.cpp b/clang/test/SemaCXX/copy-initialization.cpp index ea2db0c68e8..d219ee508f0 100644 --- a/clang/test/SemaCXX/copy-initialization.cpp +++ b/clang/test/SemaCXX/copy-initialization.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 + class X { public: explicit X(const X&); // expected-note {{candidate constructor}} @@ -58,7 +61,10 @@ namespace DR5 { namespace Ex2 { struct S { - S(S&&); // expected-warning {{C++11}} + S(S&&); +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2 {{rvalue references are a C++11 extension}} +#endif S(int); }; const S a(0); diff --git a/clang/test/SemaCXX/cxx0x-return-init-list.cpp b/clang/test/SemaCXX/cxx0x-return-init-list.cpp index 84bd89b210f..2aeec7bff7c 100644 --- a/clang/test/SemaCXX/cxx0x-return-init-list.cpp +++ b/clang/test/SemaCXX/cxx0x-return-init-list.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s // Test that a very basic variation of generalized initializer returns (that // required for libstdc++ 4.5) is supported in C++98. diff --git a/clang/test/SemaCXX/decltype-crash.cpp b/clang/test/SemaCXX/decltype-crash.cpp index 002bd4cfe73..1cebfcd72c8 100644 --- a/clang/test/SemaCXX/decltype-crash.cpp +++ b/clang/test/SemaCXX/decltype-crash.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wc++11-compat -std=c++98 %s int& a(); diff --git a/clang/test/SemaCXX/gnu-flags.cpp b/clang/test/SemaCXX/gnu-flags.cpp index 05770c53704..3cd18cabe97 100644 --- a/clang/test/SemaCXX/gnu-flags.cpp +++ b/clang/test/SemaCXX/gnu-flags.cpp @@ -1,13 +1,37 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wno-gnu +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DNONE -Wno-gnu +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DNONE -Wno-gnu + // RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wgnu +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DALL -Wgnu +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DALL -Wgnu + // RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wno-gnu \ // RUN: -Wgnu-anonymous-struct -Wredeclared-class-member \ // RUN: -Wgnu-flexible-array-union-member -Wgnu-folding-constant \ // RUN: -Wgnu-empty-struct +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DALL -Wno-gnu \ +// RUN: -Wgnu-anonymous-struct -Wredeclared-class-member \ +// RUN: -Wgnu-flexible-array-union-member -Wgnu-folding-constant \ +// RUN: -Wgnu-empty-struct +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DALL -Wno-gnu \ +// RUN: -Wgnu-anonymous-struct -Wredeclared-class-member \ +// RUN: -Wgnu-flexible-array-union-member -Wgnu-folding-constant \ +// RUN: -Wgnu-empty-struct + // RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wgnu \ // RUN: -Wno-gnu-anonymous-struct -Wno-redeclared-class-member \ // RUN: -Wno-gnu-flexible-array-union-member -Wno-gnu-folding-constant \ // RUN: -Wno-gnu-empty-struct +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DNONE -Wgnu \ +// RUN: -Wno-gnu-anonymous-struct -Wno-redeclared-class-member \ +// RUN: -Wno-gnu-flexible-array-union-member -Wno-gnu-folding-constant \ +// RUN: -Wno-gnu-empty-struct +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DNONE -Wgnu \ +// RUN: -Wno-gnu-anonymous-struct -Wno-redeclared-class-member \ +// RUN: -Wno-gnu-flexible-array-union-member -Wno-gnu-folding-constant \ +// RUN: -Wno-gnu-empty-struct + // Additional disabled tests: // %clang_cc1 -fsyntax-only -verify %s -DANONYMOUSSTRUCT -Wno-gnu -Wgnu-anonymous-struct // %clang_cc1 -fsyntax-only -verify %s -DREDECLAREDCLASSMEMBER -Wno-gnu -Wredeclared-class-member @@ -59,7 +83,7 @@ struct faum { }; -#if ALL || FOLDINGCONSTANT +#if (ALL || FOLDINGCONSTANT) && (__cplusplus <= 199711L) // C++03 or earlier modes // expected-warning@+4 {{in-class initializer for static data member is not a constant expression; folding it to a constant is a GNU extension}} #endif diff --git a/clang/test/SemaCXX/invalid-member-expr.cpp b/clang/test/SemaCXX/invalid-member-expr.cpp index 87da79a27c0..172be6b8266 100644 --- a/clang/test/SemaCXX/invalid-member-expr.cpp +++ b/clang/test/SemaCXX/invalid-member-expr.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 class X {}; @@ -23,9 +25,17 @@ void test2() { // PR6327 namespace test3 { template <class A, class B> struct pair {}; + template <class _E> class initializer_list {}; + template <typename _Tp> pair<_Tp, _Tp> minmax(initializer_list<_Tp> __l) {}; void test0() { - pair<int, int> z = minmax({}); // expected-error {{expected expression}} + pair<int, int> z = minmax({}); +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-error@-2 {{expected expression}} +#else + // expected-error@-4 {{no matching function for call to 'minmax'}} + // expected-note@-8 {{candidate template ignored: couldn't infer template argument '_Tp'}} +#endif } struct string { diff --git a/clang/test/SemaCXX/member-expr.cpp b/clang/test/SemaCXX/member-expr.cpp index 5b3393efc0c..3571fa748b8 100644 --- a/clang/test/SemaCXX/member-expr.cpp +++ b/clang/test/SemaCXX/member-expr.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 class X{ public: @@ -116,8 +118,10 @@ namespace rdar8231724 { void f(Y *y) { y->N::X1<int>; // expected-error{{'rdar8231724::N::X1' is not a member of class 'rdar8231724::Y'}} y->Z<int>::n; // expected-error{{'rdar8231724::Z<int>::n' is not a member of class 'rdar8231724::Y'}} - y->template Z<int>::n; // expected-error{{'rdar8231724::Z<int>::n' is not a member of class 'rdar8231724::Y'}} \ - // expected-warning{{'template' keyword outside of a template}} + y->template Z<int>::n; // expected-error{{'rdar8231724::Z<int>::n' is not a member of class 'rdar8231724::Y'}} +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2{{'template' keyword outside of a template}} +#endif } } diff --git a/clang/test/SemaCXX/member-pointer.cpp b/clang/test/SemaCXX/member-pointer.cpp index afb7455921e..f3adb95977a 100644 --- a/clang/test/SemaCXX/member-pointer.cpp +++ b/clang/test/SemaCXX/member-pointer.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 struct A {}; enum B { Dummy }; @@ -14,8 +16,11 @@ int (::A::*pdi2); int (A::*pfi)(int); void (*A::*ppfie)() throw(); // expected-error {{exception specifications are not allowed beyond a single level of indirection}} -int B::*pbi; // expected-warning{{use of enumeration in a nested name specifier is a C++11 extension}} \ - // expected-error {{'pbi' does not point into a class}} +int B::*pbi; +#if __cplusplus <= 199711L // C++03 or earlier modes +// expected-warning@-2 {{use of enumeration in a nested name specifier is a C++11 extension}} +#endif +// expected-error@-4 {{'pbi' does not point into a class}} int C::*pci; // expected-error {{'pci' does not point into a class}} void A::*pdv; // expected-error {{'pdv' declared as a member pointer to void}} int& A::*pdr; // expected-error {{'pdr' declared as a member pointer to a reference}} diff --git a/clang/test/SemaCXX/new-array-size-conv.cpp b/clang/test/SemaCXX/new-array-size-conv.cpp index c987c2820ad..dbdd4bd8951 100644 --- a/clang/test/SemaCXX/new-array-size-conv.cpp +++ b/clang/test/SemaCXX/new-array-size-conv.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s +// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++11 %s struct ValueInt { @@ -20,8 +22,15 @@ struct TwoValueInts : ValueInt, IndirectValueInt { }; // expected-warning{{direc void test() { - (void)new int[ValueInt(10)]; // expected-warning{{implicit conversion from array size expression of type 'ValueInt' to integral type 'int' is a C++11 extension}} - (void)new int[ValueEnum()]; // expected-warning{{implicit conversion from array size expression of type 'ValueEnum' to enumeration type 'E' is a C++11 extension}} + (void)new int[ValueInt(10)]; +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2{{implicit conversion from array size expression of type 'ValueInt' to integral type 'int' is a C++11 extension}} +#endif + + (void)new int[ValueEnum()]; +#if __cplusplus <= 199711L +// expected-warning@-2{{implicit conversion from array size expression of type 'ValueEnum' to enumeration type 'E' is a C++11 extension}} +#endif (void)new int[ValueBoth()]; // expected-error{{ambiguous conversion of array size expression of type 'ValueBoth' to an integral or enumeration type}} (void)new int[TwoValueInts()]; // expected-error{{ambiguous conversion of array size expression of type 'TwoValueInts' to an integral or enumeration type}} diff --git a/clang/test/SemaCXX/offsetof.cpp b/clang/test/SemaCXX/offsetof.cpp index e6069ac9c0a..c4b288aa05d 100644 --- a/clang/test/SemaCXX/offsetof.cpp +++ b/clang/test/SemaCXX/offsetof.cpp @@ -1,4 +1,4 @@ -// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof +// RUN: %clang_cc1 -triple x86_64-apple-darwin10.0.0 -fsyntax-only -verify %s -Winvalid-offsetof -std=c++98 struct NonPOD { virtual void f(); diff --git a/clang/test/SemaCXX/printf-block.cpp b/clang/test/SemaCXX/printf-block.cpp index 4a580037e73..b9d06d6c4fe 100644 --- a/clang/test/SemaCXX/printf-block.cpp +++ b/clang/test/SemaCXX/printf-block.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -fblocks -Wformat -verify %s -Wno-error=non-pod-varargs +// RUN: %clang_cc1 -fsyntax-only -fblocks -Wformat -verify %s -Wno-error=non-pod-varargs -std=c++98 +// RUN: %clang_cc1 -fsyntax-only -fblocks -Wformat -verify %s -Wno-error=non-pod-varargs -std=c++11 int (^block) (int, const char *,...) __attribute__((__format__(__printf__,2,3))) = ^ __attribute__((__format__(__printf__,2,3))) (int arg, const char *format,...) {return 5;}; @@ -14,5 +16,11 @@ void test_block() { HasNoCStr hncs(str); int n = 4; block(n, "%s %d", str, n); // no-warning - block(n, "%s %s", hncs, n); // expected-warning{{cannot pass non-POD object of type 'HasNoCStr' to variadic block; expected type from format string was 'char *'}} expected-warning{{format specifies type 'char *' but the argument has type 'int'}} + block(n, "%s %s", hncs, n); +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2{{cannot pass non-POD object of type 'HasNoCStr' to variadic block; expected type from format string was 'char *'}} +#else + // expected-warning@-4{{format specifies type 'char *' but the argument has type 'HasNoCStr'}} +#endif + // expected-warning@-6{{format specifies type 'char *' but the argument has type 'int'}} } diff --git a/clang/test/SemaCXX/undefined-internal.cpp b/clang/test/SemaCXX/undefined-internal.cpp index 0138967ef80..29ca5de6d41 100644 --- a/clang/test/SemaCXX/undefined-internal.cpp +++ b/clang/test/SemaCXX/undefined-internal.cpp @@ -1,7 +1,11 @@ // RUN: %clang_cc1 -fsyntax-only -verify -Wbind-to-temporary-copy %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wbind-to-temporary-copy -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -Wbind-to-temporary-copy -std=c++11 %s // Make sure we don't produce invalid IR. // RUN: %clang_cc1 -emit-llvm-only %s +// RUN: %clang_cc1 -emit-llvm-only -std=c++98 %s +// RUN: %clang_cc1 -emit-llvm-only -std=c++11 %s namespace test1 { static void foo(); // expected-warning {{function 'test1::foo' has internal linkage but is not defined}} @@ -119,7 +123,12 @@ namespace PR9323 { } void f(const Uncopyable&) {} void test() { - f(Uncopyable()); // expected-warning {{C++98 requires an accessible copy constructor}} + f(Uncopyable()); +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2 {{C++98 requires an accessible copy constructor}} +#else + // expected-warning@-4 {{copying parameter of type 'PR9323::(anonymous namespace)::Uncopyable' when binding a reference to a temporary would invoke an inaccessible constructor in C++98}} +#endif }; } |