From ab9291dcf3aebf97a9bc33929badccfb7508a96a Mon Sep 17 00:00:00 2001 From: Charles Li Date: Wed, 11 Nov 2015 19:34:47 +0000 Subject: [PATCH] [Lit Test] Updated 26 Lit tests to be C++11 compatible. Expected diagnostics have been expanded to vary by C++ dialect. RUN line has also been expanded to: default, C++98/03 and C++11. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252785 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../class.access/class.friend/p2-cxx03.cpp | 9 ++++- test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp | 14 +++++-- .../dcl.spec/dcl.type/dcl.type.elab/p3.cpp | 7 +++- .../temp.fct.spec/temp.arg.explicit/p3.cpp | 19 ++++++++-- test/CodeGen/ubsan-type-blacklist.cpp | 2 +- test/FixIt/fixit-vexing-parse.cpp | 4 +- test/SemaCXX/addr-of-overloaded-function.cpp | 7 +++- test/SemaCXX/const-cast.cpp | 13 +++++-- test/SemaCXX/convert-to-bool.cpp | 18 +++++++-- test/SemaCXX/copy-initialization.cpp | 8 +++- test/SemaCXX/cxx0x-return-init-list.cpp | 2 +- test/SemaCXX/decltype-crash.cpp | 2 +- test/SemaCXX/gnu-flags.cpp | 26 ++++++++++++- test/SemaCXX/invalid-member-expr.cpp | 12 +++++- test/SemaCXX/member-expr.cpp | 8 +++- test/SemaCXX/member-pointer.cpp | 9 ++++- test/SemaCXX/new-array-size-conv.cpp | 13 ++++++- test/SemaCXX/offsetof.cpp | 2 +- test/SemaCXX/printf-block.cpp | 10 ++++- test/SemaCXX/undefined-internal.cpp | 11 +++++- test/SemaObjCXX/crash.mm | 8 +++- test/SemaObjCXX/vararg-non-pod.mm | 9 ++++- test/SemaTemplate/default-arguments.cpp | 13 +++++-- test/SemaTemplate/temp_class_spec_neg.cpp | 12 +++++- test/SemaTemplate/typename-specifier-4.cpp | 9 ++++- test/SemaTemplate/typename-specifier.cpp | 38 ++++++++++++++----- 26 files changed, 234 insertions(+), 51 deletions(-) diff --git a/test/CXX/class.access/class.friend/p2-cxx03.cpp b/test/CXX/class.access/class.friend/p2-cxx03.cpp index f8cabfd78a..88b2ea3a9b 100644 --- a/test/CXX/class.access/class.friend/p2-cxx03.cpp +++ b/test/CXX/class.access/class.friend/p2-cxx03.cpp @@ -1,7 +1,14 @@ // 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 template class X0 { - friend T; // expected-warning{{non-class friend type 'T' is a C++11 extension}} + friend T; +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2{{non-class friend type 'T' is a C++11 extension}} +#else + // expected-no-diagnostics +#endif }; class X1 { }; diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp index 5d1e6fb85c..08b22c1186 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.fct.spec/p6.cpp @@ -1,10 +1,15 @@ // RUN: %clang_cc1 -verify %s +// RUN: %clang_cc1 -verify -std=c++98 %s +// RUN: %clang_cc1 -verify -std=c++11 %s class A { public: explicit A(); - 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 explicit void f0(); // expected-error {{'explicit' can only be applied to a constructor or conversion function}} @@ -12,8 +17,11 @@ public: }; explicit A::A() { } // expected-error {{'explicit' can only be specified inside the class definition}} -explicit A::operator bool() { return false; } // expected-warning {{explicit conversion functions are a C++11 extension}}\ - // expected-error {{'explicit' can only be specified inside the class definition}} +explicit A::operator bool() { return false; } +#if __cplusplus <= 199711L // C++03 or earlier modes +// expected-warning@-2 {{explicit conversion functions are a C++11 extension}} +#endif +// expected-error@-4 {{'explicit' can only be specified inside the class definition}} class B { friend explicit A::A(); // expected-error {{'explicit' is invalid in friend declarations}} diff --git a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp index 40e754082b..1940651840 100644 --- a/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.cpp +++ b/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.elab/p3.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 A {}; // expected-note 4 {{previous use is here}} enum E {}; @@ -14,7 +16,10 @@ class A1 { friend union A; // expected-error {{use of 'A' with tag type that does not match previous declaration}} friend enum A; // expected-error {{use of 'A' with tag type that does not match previous declaration}} - friend enum E; // expected-warning {{befriending enumeration type 'enum E' is a C++11 extension}} + friend enum E; +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2 {{befriending enumeration type 'enum E' is a C++11 extension}} +#endif }; template struct B { // expected-note {{previous use is here}} diff --git a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp b/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp index 5556f35dbf..bfe08a67a4 100644 --- a/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp +++ b/test/CXX/temp/temp.fct.spec/temp.arg.explicit/p3.cpp @@ -1,11 +1,24 @@ // 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 template X f(Y,Z); // expected-note {{candidate template ignored: couldn't infer template argument 'X'}} void g() { - f("aa",3.0); // expected-warning{{conversion from string literal to 'char *' is deprecated}} - f("aa",3.0); // Z is deduced to be double \ - // expected-warning{{conversion from string literal to 'char *' is deprecated}} + f("aa",3.0); +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2{{conversion from string literal to 'char *' is deprecated}} +#else + // expected-warning@-4{{ISO C++11 does not allow conversion from string literal to 'char *'}} +#endif + + f("aa",3.0); // Z is deduced to be double +#if __cplusplus <= 199711L + // expected-warning@-2{{conversion from string literal to 'char *' is deprecated}} +#else + // expected-warning@-4{{ISO C++11 does not allow conversion from string literal to 'char *'}} +#endif + f("aa",3.0); // Y is deduced to be char*, and // Z is deduced to be double f("aa",3.0); // expected-error{{no matching}} diff --git a/test/CodeGen/ubsan-type-blacklist.cpp b/test/CodeGen/ubsan-type-blacklist.cpp index b3137e7806..26b7aa877d 100644 --- a/test/CodeGen/ubsan-type-blacklist.cpp +++ b/test/CodeGen/ubsan-type-blacklist.cpp @@ -14,7 +14,7 @@ Bar bar; // DEFAULT: @_Z7checkmev // TYPE: @_Z7checkmev void checkme() { -// DEFAULT: call void @__ubsan_handle_dynamic_type_cache_miss({{.*}} (%class.Bar* @bar to +// DEFAULT: call void @__ubsan_handle_dynamic_type_cache_miss({{.*}} ({{.*}}* @bar to // TYPE-NOT: @__ubsan_handle_dynamic_type_cache_miss Foo* foo = static_cast(&bar); // down-casting // DEFAULT: ret void diff --git a/test/FixIt/fixit-vexing-parse.cpp b/test/FixIt/fixit-vexing-parse.cpp index 79d8cad6bb..0232f5dbb0 100644 --- a/test/FixIt/fixit-vexing-parse.cpp +++ b/test/FixIt/fixit-vexing-parse.cpp @@ -1,5 +1,5 @@ -// RUN: %clang_cc1 -verify -x c++ %s -// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -verify -x c++ -std=c++98 %s +// RUN: not %clang_cc1 -fdiagnostics-parseable-fixits -x c++ -std=c++98 %s 2>&1 | FileCheck %s struct S { int n; diff --git a/test/SemaCXX/addr-of-overloaded-function.cpp b/test/SemaCXX/addr-of-overloaded-function.cpp index 09f280bc1d..cca847b4d2 100644 --- a/test/SemaCXX/addr-of-overloaded-function.cpp +++ b/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 void q4(); // expected-note{{possible target for call}} - template // expected-warning{{default template arguments for a function template are a C++11 extension}} + template +#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/test/SemaCXX/const-cast.cpp b/test/SemaCXX/const-cast.cpp index 330e18661b..87df61cbc7 100644 --- a/test/SemaCXX/const-cast.cpp +++ b/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(&fp); int const A::* const A::*icapcap = 0; int A::* A::* iapap = const_cast(icapcap); - (void)const_cast(A()); // expected-warning {{C++11}} - + (void)const_cast(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(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(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(0); // expected-error {{const_cast from rvalue to reference type 'int &&'}} expected-warning {{C++11}} + (void)const_cast(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/test/SemaCXX/convert-to-bool.cpp b/test/SemaCXX/convert-to-bool.cpp index b52f11c93d..117b50899b 100644 --- a/test/SemaCXX/convert-to-bool.cpp +++ b/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/test/SemaCXX/copy-initialization.cpp b/test/SemaCXX/copy-initialization.cpp index ea2db0c68e..d219ee508f 100644 --- a/test/SemaCXX/copy-initialization.cpp +++ b/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/test/SemaCXX/cxx0x-return-init-list.cpp b/test/SemaCXX/cxx0x-return-init-list.cpp index 84bd89b210..2aeec7bff7 100644 --- a/test/SemaCXX/cxx0x-return-init-list.cpp +++ b/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/test/SemaCXX/decltype-crash.cpp b/test/SemaCXX/decltype-crash.cpp index 002bd4cfe7..1cebfcd72c 100644 --- a/test/SemaCXX/decltype-crash.cpp +++ b/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/test/SemaCXX/gnu-flags.cpp b/test/SemaCXX/gnu-flags.cpp index 05770c5370..3cd18cabe9 100644 --- a/test/SemaCXX/gnu-flags.cpp +++ b/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/test/SemaCXX/invalid-member-expr.cpp b/test/SemaCXX/invalid-member-expr.cpp index 87da79a27c..172be6b826 100644 --- a/test/SemaCXX/invalid-member-expr.cpp +++ b/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 struct pair {}; + template class initializer_list {}; + template pair<_Tp, _Tp> minmax(initializer_list<_Tp> __l) {}; void test0() { - pair z = minmax({}); // expected-error {{expected expression}} + pair 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/test/SemaCXX/member-expr.cpp b/test/SemaCXX/member-expr.cpp index 5b3393efc0..3571fa748b 100644 --- a/test/SemaCXX/member-expr.cpp +++ b/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; // expected-error{{'rdar8231724::N::X1' is not a member of class 'rdar8231724::Y'}} y->Z::n; // expected-error{{'rdar8231724::Z::n' is not a member of class 'rdar8231724::Y'}} - y->template Z::n; // expected-error{{'rdar8231724::Z::n' is not a member of class 'rdar8231724::Y'}} \ - // expected-warning{{'template' keyword outside of a template}} + y->template Z::n; // expected-error{{'rdar8231724::Z::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/test/SemaCXX/member-pointer.cpp b/test/SemaCXX/member-pointer.cpp index afb7455921..f3adb95977 100644 --- a/test/SemaCXX/member-pointer.cpp +++ b/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/test/SemaCXX/new-array-size-conv.cpp b/test/SemaCXX/new-array-size-conv.cpp index c987c2820a..dbdd4bd895 100644 --- a/test/SemaCXX/new-array-size-conv.cpp +++ b/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/test/SemaCXX/offsetof.cpp b/test/SemaCXX/offsetof.cpp index e6069ac9c0..c4b288aa05 100644 --- a/test/SemaCXX/offsetof.cpp +++ b/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/test/SemaCXX/printf-block.cpp b/test/SemaCXX/printf-block.cpp index 4a580037e7..b9d06d6c4f 100644 --- a/test/SemaCXX/printf-block.cpp +++ b/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/test/SemaCXX/undefined-internal.cpp b/test/SemaCXX/undefined-internal.cpp index 0138967ef8..29ca5de6d4 100644 --- a/test/SemaCXX/undefined-internal.cpp +++ b/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 }; } diff --git a/test/SemaObjCXX/crash.mm b/test/SemaObjCXX/crash.mm index 521b923cc0..19cf309982 100644 --- a/test/SemaObjCXX/crash.mm +++ b/test/SemaObjCXX/crash.mm @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only %s -verify +// RUN: %clang_cc1 -fsyntax-only -std=c++98 %s -verify +// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -verify // namespace std { @@ -18,6 +20,8 @@ struct EvilStruct { typedef std::pair IntegerPair; -template void f(Ts); // expected-error {{unexpanded}} expected-warning {{extension}} - +template void f(Ts); // expected-error {{unexpanded}} +#if __cplusplus <= 199711L // C++03 or earlier modes +// expected-warning@-2 {{variadic templates are a C++11 extension}} +#endif @end diff --git a/test/SemaObjCXX/vararg-non-pod.mm b/test/SemaObjCXX/vararg-non-pod.mm index 5a6281d71c..daf9aa92b5 100644 --- a/test/SemaObjCXX/vararg-non-pod.mm +++ b/test/SemaObjCXX/vararg-non-pod.mm @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-error=non-pod-varargs +// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-error=non-pod-varargs -std=c++98 +// RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-error=non-pod-varargs -std=c++11 extern char version[]; @@ -17,7 +19,12 @@ void t1(D *d) { C c(10); - [d g:10, c]; // expected-warning{{cannot pass object of non-POD type 'C' through variadic method; call will abort at runtime}} + [d g:10, c]; +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2{{cannot pass object of non-POD type 'C' through variadic method; call will abort at runtime}} +#else + // expected-no-diagnostics@-4 +#endif [d g:10, version]; } diff --git a/test/SemaTemplate/default-arguments.cpp b/test/SemaTemplate/default-arguments.cpp index 37d144b719..740a5a9d07 100644 --- a/test/SemaTemplate/default-arguments.cpp +++ b/test/SemaTemplate/default-arguments.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 template struct X; // expected-note{{template is declared here}} X *x1; @@ -142,7 +144,10 @@ namespace PR9643 { namespace PR16288 { template struct S { - template // expected-warning {{C++11}} + template +#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 f(); }; template @@ -152,8 +157,10 @@ namespace PR16288 { namespace DR1635 { template struct X { - template static void f(int) {} // expected-error {{type 'int' cannot be used prior to '::' because it has no members}} \ - // expected-warning {{C++11}} + template static void f(int) {} // expected-error {{type 'int' cannot be used prior to '::' because it has no members}} +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-warning@-2 {{default template arguments for a function template are a C++11 extension}} +#endif static void f(...) {} }; diff --git a/test/SemaTemplate/temp_class_spec_neg.cpp b/test/SemaTemplate/temp_class_spec_neg.cpp index be5fbb154e..1c77038ab8 100644 --- a/test/SemaTemplate/temp_class_spec_neg.cpp +++ b/test/SemaTemplate/temp_class_spec_neg.cpp @@ -1,15 +1,23 @@ // 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 template struct vector; // C++ [temp.class.spec]p6: namespace N { namespace M { - template struct A; // expected-note{{here}} + template struct A; +#if __cplusplus <= 199711L // C++03 or earlier modes + // expected-note@-2{{explicitly specialized declaration is here}} +#endif } } template -struct N::M::A { }; // expected-warning{{C++11 extension}} +struct N::M::A { }; +#if __cplusplus <= 199711L +// expected-warning@-2{{first declaration of class template partial specialization of 'A' outside namespace 'M' is a C++11 extension}} +#endif // C++ [temp.class.spec]p9 // bullet 1 diff --git a/test/SemaTemplate/typename-specifier-4.cpp b/test/SemaTemplate/typename-specifier-4.cpp index 44cf966e33..2856c99b6d 100644 --- a/test/SemaTemplate/typename-specifier-4.cpp +++ b/test/SemaTemplate/typename-specifier-4.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 template struct is_same { static const bool value = false; @@ -27,8 +29,11 @@ struct make_pair { int a0[is_same::type, pair >::value? 1 : -1]; int a1[is_same< - typename make_pair::template apply, // expected-warning{{'template' keyword outside of a template}} \ - // expected-warning{{'typename' occurs outside of a template}} + typename make_pair::template apply, +#if __cplusplus <= 199711L // C++03 and earlier modes + // expected-warning@-2 {{'template' keyword outside of a template}} + // expected-warning@-3 {{'typename' occurs outside of a template}} +#endif make_pair::apply >::value? 1 : -1]; diff --git a/test/SemaTemplate/typename-specifier.cpp b/test/SemaTemplate/typename-specifier.cpp index 602e903063..b36a103b65 100644 --- a/test/SemaTemplate/typename-specifier.cpp +++ b/test/SemaTemplate/typename-specifier.cpp @@ -1,5 +1,9 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unused // RUN: %clang_cc1 -fsyntax-only -verify %s -Wno-unused -fms-compatibility -DMSVC +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -Wno-unused +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -Wno-unused -fms-compatibility -DMSVC +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wno-unused +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -Wno-unused -fms-compatibility -DMSVC namespace N { struct A { typedef int type; @@ -16,22 +20,38 @@ namespace N { int i; -typename N::A::type *ip1 = &i; // expected-warning{{'typename' occurs outside of a template}} -typename N::B::type *ip2 = &i; // expected-error{{no type named 'type' in 'N::B'}} \ -// expected-warning{{'typename' occurs outside of a template}} -typename N::C::type *ip3 = &i; // expected-error{{typename specifier refers to non-type member 'type'}} \ -// expected-warning{{'typename' occurs outside of a template}} +typename N::A::type *ip1 = &i; +#if __cplusplus <= 199711L // C++03 or earlier modes +// expected-warning@-2 {{'typename' occurs outside of a template}} +#endif +typename N::B::type *ip2 = &i; // expected-error{{no type named 'type' in 'N::B'}} +#if __cplusplus <= 199711L +// expected-warning@-2 {{'typename' occurs outside of a template}} +#endif +typename N::C::type *ip3 = &i; // expected-error{{typename specifier refers to non-type member 'type'}} +#if __cplusplus <= 199711L +// expected-warning@-2 {{'typename' occurs outside of a template}} +#endif void test(double d) { - typename N::A::type f(typename N::A::type(a)); // expected-warning{{disambiguated as a function declaration}} \ - // expected-note{{add a pair of parentheses}} expected-warning 2{{'typename' occurs outside of a template}} + typename N::A::type f(typename N::A::type(a)); // expected-warning{{disambiguated as a function declaration}} + // expected-note@-1 {{add a pair of parentheses}} +#if __cplusplus <= 199711L + // expected-warning@-3 2{{'typename' occurs outside of a template}} +#endif int five = f(5); using namespace N; - for (typename A::type i = 0; i < 10; ++i) // expected-warning{{'typename' occurs outside of a template}} + for (typename A::type i = 0; i < 10; ++i) +#if __cplusplus <= 199711L +// expected-warning@-2 {{'typename' occurs outside of a template}} +#endif five += 1; - const typename N::A::type f2(d); // expected-warning{{'typename' occurs outside of a template}} + const typename N::A::type f2(d); +#if __cplusplus <= 199711L +// expected-warning@-2 {{'typename' occurs outside of a template}} +#endif } namespace N { -- 2.40.0