From 43890ab2a0edf63c61f574a9f7a4fd0c003508b7 Mon Sep 17 00:00:00 2001 From: Charles Li Date: Thu, 10 Dec 2015 01:07:17 +0000 Subject: [PATCH] [Lit Test] Updated 20 Lit tests to be C++11 compatible. This is the 5th Lit test patch. Expanded expected diagnostics to vary by C++ dialect. Expanded RUN line to: default, C++98/03 and C++11. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@255196 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CXX/class/class.nest/p1.cpp | 7 ++- test/Parser/cxx-casting.cpp | 59 +++++++++++++++---- test/Parser/cxx-reference.cpp | 7 ++- test/Parser/cxx-template-argument.cpp | 39 ++++++++---- test/Parser/cxx-typeof.cpp | 9 ++- test/Parser/objc-init.m | 12 +++- test/Parser/objcxx-lambda-expressions-neg.mm | 10 +++- test/SemaCXX/decl-expr-ambiguity.cpp | 5 ++ test/SemaCXX/overload-call.cpp | 45 +++++++++++--- test/SemaCXX/pragma-init_seg.cpp | 7 +++ test/SemaCXX/typo-correction-delayed.cpp | 8 ++- test/SemaCXX/unknown-type-name.cpp | 8 ++- test/SemaCXX/writable-strings-deprecated.cpp | 30 ++++++---- test/SemaObjCXX/message.mm | 19 +++++- test/SemaTemplate/instantiate-function-2.cpp | 8 ++- test/SemaTemplate/instantiate-static-var.cpp | 11 +++- .../nested-name-spec-template.cpp | 13 +++- test/SemaTemplate/overload-candidates.cpp | 26 ++++++-- .../SemaTemplate/partial-spec-instantiate.cpp | 9 ++- test/SemaTemplate/temp_arg_template.cpp | 25 ++++++-- 20 files changed, 291 insertions(+), 66 deletions(-) diff --git a/test/CXX/class/class.nest/p1.cpp b/test/CXX/class/class.nest/p1.cpp index b0341da7c2..59bf50f424 100644 --- a/test/CXX/class/class.nest/p1.cpp +++ b/test/CXX/class/class.nest/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 class Outer { int x; @@ -7,7 +9,10 @@ class Outer { // C++11 does relax this rule (see 5.1.1.10) in the first case, but we need to enforce it in C++03 mode. class Inner { - static char a[sizeof(x)]; // expected-error {{invalid use of non-static data member 'x'}} + static char a[sizeof(x)]; +#if __cplusplus <= 199711L + // expected-error@-2 {{invalid use of non-static data member 'x'}} +#endif static char b[sizeof(sx)]; // okay static char c[sizeof(f)]; // expected-error {{call to non-static member function without an object argument}} }; diff --git a/test/Parser/cxx-casting.cpp b/test/Parser/cxx-casting.cpp index d2c97b88b8..43885bff27 100644 --- a/test/Parser/cxx-casting.cpp +++ b/test/Parser/cxx-casting.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 char *const_cast_test(const char *var) { @@ -41,10 +43,25 @@ namespace test1 { typedef char* c; typedef A* a; void test2(char x, struct B * b) { - (void)const_cast<::c>(&x); // expected-error{{found '<::' after a const_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} - (void)dynamic_cast<::a>(b); // expected-error{{found '<::' after a dynamic_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} - (void)reinterpret_cast<::c>(x); // expected-error{{found '<::' after a reinterpret_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} - (void)static_cast<::c>(&x); // expected-error{{found '<::' after a static_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} + (void)const_cast<::c>(&x); +#if __cplusplus <= 199711L + // expected-error@-2 {{found '<::' after a const_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} +#endif + + (void)dynamic_cast<::a>(b); +#if __cplusplus <= 199711L + // expected-error@-2 {{found '<::' after a dynamic_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} +#endif + + (void)reinterpret_cast<::c>(x); +#if __cplusplus <= 199711L + // expected-error@-2 {{found '<::' after a reinterpret_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} +#endif + + (void)static_cast<::c>(&x); +#if __cplusplus <= 199711L + // expected-error@-2 {{found '<::' after a static_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} +#endif // Do not do digraph correction. (void)static_cast<: :c>(&x); //\ @@ -64,8 +81,15 @@ void test2(char x, struct B * b) { (void)static_cast<:C c>(&x); // expected-error {{expected '<' after 'static_cast'}} expected-error 2{{}} expected-note{{}} #define LCC <:: - test1::A LCC B> e; // expected-error{{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} - (void)static_cast LCC c>(&x); // expected-error{{found '<::' after a static_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} + test1::A LCC B> e; +#if __cplusplus <= 199711L + // expected-error@-2 {{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} +#endif + + (void)static_cast LCC c>(&x); +#if __cplusplus <= 199711L + // expected-error@-2 {{found '<::' after a static_cast which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} +#endif } // This note comes from "::D[:F> A5;" @@ -74,10 +98,25 @@ template void E() {}; class F {}; void test3() { - ::D<::F> A1; // expected-error{{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} - D<::F> A2; // expected-error{{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} - ::E<::F>(); // expected-error{{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} - E<::F>(); // expected-error{{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} + ::D<::F> A1; +#if __cplusplus <= 199711L + // expected-error@-2 {{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} +#endif + + D<::F> A2; +#if __cplusplus <= 199711L + // expected-error@-2 {{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} +#endif + + ::E<::F>(); +#if __cplusplus <= 199711L + // expected-error@-2 {{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} +#endif + + E<::F>(); +#if __cplusplus <= 199711L + // expected-error@-2 {{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} +#endif ::D< ::F> A3; D< ::F> A4; diff --git a/test/Parser/cxx-reference.cpp b/test/Parser/cxx-reference.cpp index b62638b1a4..58bd7ab607 100644 --- a/test/Parser/cxx-reference.cpp +++ b/test/Parser/cxx-reference.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 extern char *bork; char *& bar = bork; @@ -18,4 +20,7 @@ int & volatile Y = val; // expected-error {{'volatile' qualifier may not be appl int & const volatile Z = val; /* expected-error {{'const' qualifier may not be applied}} \ expected-error {{'volatile' qualifier may not be applied}} */ -typedef int && RV; // expected-warning {{rvalue references are a C++11 extension}} +typedef int && RV; +#if __cplusplus <= 199711L +// expected-warning@-2 {{rvalue references are a C++11 extension}} +#endif diff --git a/test/Parser/cxx-template-argument.cpp b/test/Parser/cxx-template-argument.cpp index c9cc6b8079..9b8ca985dd 100644 --- a/test/Parser/cxx-template-argument.cpp +++ b/test/Parser/cxx-template-argument.cpp @@ -1,5 +1,9 @@ // 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 // RUN: %clang_cc1 -fsyntax-only -verify %s -fdelayed-template-parsing +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -fdelayed-template-parsing +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -fdelayed-template-parsing template struct A {}; @@ -22,7 +26,10 @@ namespace greatergreater { void (*p)() = &t; (void)(&t==p); // expected-error {{use '> ='}} (void)(&t>=p); // expected-error {{use '> >'}} - (void)(&t>>=p); // expected-error {{use '> >'}} + (void)(&t>>=p); +#if __cplusplus <= 199711L + // expected-error@-2 {{use '> >'}} +#endif (void)(&t>==p); // expected-error {{use '> >'}} expected-error {{use '> ='}} } } @@ -72,13 +79,17 @@ namespace pr16225add { { }; template struct foo5 : - UnknownBase> // expected-error {{unknown template name 'UnknownBase'}} \ - // expected-error {{use '> >'}} + UnknownBase> // expected-error {{unknown template name 'UnknownBase'}} +#if __cplusplus <= 199711L + // expected-error@-2 {{use '> >'}} +#endif { }; template struct foo6 : - UnknownBase>, // expected-error {{unknown template name 'UnknownBase'}} \ - // expected-error {{use '> >'}} + UnknownBase>, // expected-error {{unknown template name 'UnknownBase'}} +#if __cplusplus <= 199711L + // expected-error@-2 {{use '> >'}} +#endif Known // expected-error {{too few template arguments for class template 'Known'}} { }; @@ -87,18 +98,24 @@ namespace pr16225add { { }; template struct foo8 : - UnknownBase,X> // expected-error {{unknown template name 'UnknownBase'}} \ - // expected-error {{use '> >'}} + UnknownBase,X> // expected-error {{unknown template name 'UnknownBase'}} +#if __cplusplus <= 199711L + // expected-error@-2 {{use '> >'}} +#endif { }; template struct foo9 : - UnknownBase,X> // expected-error {{unknown template name 'UnknownBase'}} \ - // expected-error {{use '> >'}} + UnknownBase,X> // expected-error {{unknown template name 'UnknownBase'}} +#if __cplusplus <= 199711L + // expected-error@-2 {{use '> >'}} +#endif { }; template struct foo10 : - UnknownBase,X>> // expected-error {{unknown template name 'UnknownBase'}} \ - // expected-error {{use '> >'}} + UnknownBase,X>> // expected-error {{unknown template name 'UnknownBase'}} +#if __cplusplus <= 199711L + // expected-error@-2 {{use '> >'}} +#endif { }; template struct foo11 : diff --git a/test/Parser/cxx-typeof.cpp b/test/Parser/cxx-typeof.cpp index 1ec6e29b13..c9651b4e1c 100644 --- a/test/Parser/cxx-typeof.cpp +++ b/test/Parser/cxx-typeof.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++98 %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=gnu++11 %s static void test() { int *pi; @@ -9,5 +11,10 @@ static void test() { // Part of rdar://problem/8347416; from the gcc test suite. struct S { int i; - __typeof(S::i) foo(); // expected-error {{invalid use of non-static data member 'i'}} + __typeof(S::i) foo(); +#if __cplusplus <= 199711L + // expected-error@-2 {{invalid use of non-static data member 'i'}} +#else + // expected-no-diagnostics +#endif }; diff --git a/test/Parser/objc-init.m b/test/Parser/objc-init.m index c9d7d5d301..088e385f95 100644 --- a/test/Parser/objc-init.m +++ b/test/Parser/objc-init.m @@ -1,5 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -pedantic -Wno-objc-root-class %s // RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-objc-root-class %s +// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-objc-root-class -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile -verify -x objective-c++ -Wno-objc-root-class -std=c++11 %s // rdar://5707001 @interface NSNumber; @@ -36,8 +38,16 @@ void test5(NSNumber *x) { }; struct SomeStruct z = { - .x = [x METH2], // ok. + .x = [x METH2], // ok in C++98. +#if __cplusplus >= 201103L + // expected-error@-2 {{non-constant-expression cannot be narrowed from type 'unsigned int' to 'int' in initializer list}} + // expected-note@-3 {{insert an explicit cast to silence this issue}} +#endif .x [x METH2] // expected-error {{expected '=' or another designator}} +#if __cplusplus >= 201103L + // expected-error@-2 {{non-constant-expression cannot be narrowed from type 'unsigned int' to 'int' in initializer list}} + // expected-note@-3 {{insert an explicit cast to silence this issue}} +#endif }; } diff --git a/test/Parser/objcxx-lambda-expressions-neg.mm b/test/Parser/objcxx-lambda-expressions-neg.mm index 7cdb1a292e..b2fe39dfbf 100644 --- a/test/Parser/objcxx-lambda-expressions-neg.mm +++ b/test/Parser/objcxx-lambda-expressions-neg.mm @@ -1,5 +1,13 @@ // RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -Wno-unused-value -verify -std=c++11 %s int main() { - []{}; // expected-error {{expected expression}} + []{}; +#if __cplusplus <= 199711L + // expected-error@-2 {{expected expression}} +#else + // expected-no-diagnostics +#endif + } diff --git a/test/SemaCXX/decl-expr-ambiguity.cpp b/test/SemaCXX/decl-expr-ambiguity.cpp index 6abfb2f328..1b1f7dc8a7 100644 --- a/test/SemaCXX/decl-expr-ambiguity.cpp +++ b/test/SemaCXX/decl-expr-ambiguity.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors %s +// RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors -std=gnu++98 %s +// RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors -std=gnu++11 %s // RUN: %clang_cc1 -Wno-int-to-pointer-cast -fsyntax-only -verify -pedantic-errors -x objective-c++ %s void f() { @@ -60,6 +62,9 @@ namespace N { func(); // expected-warning {{function declaration}} expected-note {{replace parentheses with an initializer}} S s(); // expected-warning {{function declaration}} +#if __cplusplus >= 201103L + // expected-note@-2 {{replace parentheses with an initializer to declare a variable}} +#endif } void nonEmptyParens() { int f = 0, // g = 0; expected-note {{change this ',' to a ';' to call 'func2'}} diff --git a/test/SemaCXX/overload-call.cpp b/test/SemaCXX/overload-call.cpp index 7c6fe2b7e4..3d286a94a0 100644 --- a/test/SemaCXX/overload-call.cpp +++ b/test/SemaCXX/overload-call.cpp @@ -1,4 +1,7 @@ // RUN: %clang_cc1 -triple %itanium_abi_triple -pedantic -verify %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -pedantic -verify -std=c++98 %s +// RUN: %clang_cc1 -triple %itanium_abi_triple -pedantic -verify -std=c++11 %s + int* f(int) { return 0; } float* f(float) { return 0; } void f(); @@ -53,8 +56,19 @@ int* k(char*); double* k(bool); void test_k() { - int* ip1 = k("foo"); // expected-warning{{conversion from string literal to 'char *' is deprecated}} - int* ip2 = k(("foo")); // expected-warning{{conversion from string literal to 'char *' is deprecated}} + int* ip1 = k("foo"); +#if __cplusplus <= 199711L + // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}} +#else + // expected-error@-4 {{cannot initialize a variable of type 'int *' with an rvalue of type 'double *'}} +#endif + + int* ip2 = k(("foo")); +#if __cplusplus <= 199711L + // expected-warning@-2 {{conversion from string literal to 'char *' is deprecated}} +#else + // expected-error@-4 {{cannot initialize a variable of type 'int *' with an rvalue of type 'double *'}} +#endif double* dp1 = k(L"foo"); } @@ -62,7 +76,12 @@ int* l(wchar_t*); double* l(bool); void test_l() { - int* ip1 = l(L"foo"); // expected-warning{{conversion from string literal to 'wchar_t *' is deprecated}} + int* ip1 = l(L"foo"); +#if __cplusplus <= 199711L + // expected-warning@-2 {{conversion from string literal to 'wchar_t *' is deprecated}} +#else + // expected-error@-4 {{cannot initialize a variable of type 'int *' with an rvalue of type 'double *'}} +#endif double* dp1 = l("foo"); } @@ -80,8 +99,12 @@ class E; void test_n(E* e) { char ca[7]; int* ip1 = n(ca); - int* ip2 = n("foo"); // expected-warning{{conversion from string literal to 'char *' is deprecated}} - + int* ip2 = n("foo"); +#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 float fa[7]; double* dp1 = n(fa); @@ -593,8 +616,16 @@ void test5() { namespace PR20218 { void f(void (*const &)()); // expected-note 2{{candidate}} - void f(void (&&)()) = delete; // expected-note 2{{candidate}} expected-warning 2{{extension}} - void g(void (&&)()) = delete; // expected-note 2{{candidate}} expected-warning 2{{extension}} + void f(void (&&)()) = delete; // expected-note 2{{candidate}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{rvalue references are a C++11 extension}} + // expected-warning@-3 {{deleted function definitions are a C++11 extension}} +#endif + void g(void (&&)()) = delete; // expected-note 2{{candidate}} +#if __cplusplus <= 199711L + // expected-warning@-2 {{rvalue references are a C++11 extension}} + // expected-warning@-3 {{deleted function definitions are a C++11 extension}} +#endif void g(void (*const &)()); // expected-note 2{{candidate}} void x(); diff --git a/test/SemaCXX/pragma-init_seg.cpp b/test/SemaCXX/pragma-init_seg.cpp index e18d0e6814..1b22939f18 100644 --- a/test/SemaCXX/pragma-init_seg.cpp +++ b/test/SemaCXX/pragma-init_seg.cpp @@ -1,5 +1,9 @@ // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple x86_64-pc-win32 +// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -std=c++98 %s -triple x86_64-pc-win32 +// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -std=c++11 %s -triple x86_64-pc-win32 // RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -triple i386-apple-darwin13.3.0 +// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -std=c++98 %s -triple i386-apple-darwin13.3.0 +// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions -std=c++11 %s -triple i386-apple-darwin13.3.0 #ifndef __APPLE__ #pragma init_seg(L".my_seg") // expected-warning {{expected 'compiler', 'lib', 'user', or a string literal}} @@ -19,3 +23,6 @@ int f(); int __declspec(thread) x = f(); // expected-error {{initializer for thread-local variable must be a constant expression}} +#if __cplusplus >= 201103L +// expected-note@-2 {{use 'thread_local' to allow this}} +#endif diff --git a/test/SemaCXX/typo-correction-delayed.cpp b/test/SemaCXX/typo-correction-delayed.cpp index 121863d172..610d439713 100644 --- a/test/SemaCXX/typo-correction-delayed.cpp +++ b/test/SemaCXX/typo-correction-delayed.cpp @@ -1,4 +1,6 @@ // RUN: %clang_cc1 -fsyntax-only -verify -Wno-c++11-extensions %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -Wno-c++11-extensions %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s struct A {}; struct B {}; @@ -109,8 +111,10 @@ S<1> s; namespace foo {} void test_paren_suffix() { - foo::bar({5, 6}); // expected-error-re {{no member named 'bar' in namespace 'foo'{{$}}}} \ - // expected-error {{expected expression}} + foo::bar({5, 6}); // expected-error-re {{no member named 'bar' in namespace 'foo'{{$}}}} +#if __cplusplus <= 199711L + // expected-error@-2 {{expected expression}} +#endif } const int kNum = 10; // expected-note {{'kNum' declared here}} diff --git a/test/SemaCXX/unknown-type-name.cpp b/test/SemaCXX/unknown-type-name.cpp index 9d28c310ed..2a9748e3ab 100644 --- a/test/SemaCXX/unknown-type-name.cpp +++ b/test/SemaCXX/unknown-type-name.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 // PR3990 namespace N { @@ -95,7 +97,11 @@ template int h(T::type x, char); // expected-error{{missing 'typenam template int junk1(T::junk); // expected-warning{{variable templates are a C++14 extension}} template int junk2(T::junk) throw(); // expected-error{{missing 'typename'}} -template int junk3(T::junk) = delete; // expected-error{{missing 'typename'}} expected-warning{{C++11}} +template int junk3(T::junk) = delete; // expected-error{{missing 'typename'}} +#if __cplusplus <= 199711L +//expected-warning@-2 {{deleted function definitions are a C++11 extension}} +#endif + template int junk4(T::junk j); // expected-error{{missing 'typename'}} // FIXME: We can tell this was intended to be a function because it does not diff --git a/test/SemaCXX/writable-strings-deprecated.cpp b/test/SemaCXX/writable-strings-deprecated.cpp index f925833498..7de11b59dd 100644 --- a/test/SemaCXX/writable-strings-deprecated.cpp +++ b/test/SemaCXX/writable-strings-deprecated.cpp @@ -1,25 +1,31 @@ -// RUN: %clang_cc1 -fsyntax-only -Wno-deprecated-writable-strings -verify %s -// RUN: %clang_cc1 -fsyntax-only -Wno-deprecated -Wdeprecated-increment-bool -verify %s -// RUN: %clang_cc1 -fsyntax-only -fwritable-strings -verify %s -// RUN: %clang_cc1 -fsyntax-only -Wno-write-strings -verify %s -// RUN: %clang_cc1 -fsyntax-only -Werror=c++11-compat -verify %s -DERROR -// RUN: %clang_cc1 -fsyntax-only -Werror=deprecated -Wno-error=deprecated-increment-bool -verify %s -DERROR -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -Wno-deprecated -Wdeprecated-increment-bool +// RUN: %clang_cc1 -fsyntax-only -verify %s -DWARNING +// RUN: %clang_cc1 -fsyntax-only -std=c++98 -verify %s -DWARNING +// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wno-deprecated-writable-strings -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wno-deprecated -Wdeprecated-increment-bool -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c++98 -fwritable-strings -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Wno-write-strings -verify %s +// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror=c++11-compat -verify %s -DERROR +// RUN: %clang_cc1 -fsyntax-only -std=c++98 -Werror=deprecated -Wno-error=deprecated-increment-bool -verify %s -DERROR +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -DWARNING +// RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -Wno-deprecated -Wdeprecated-increment-bool -DWARNING // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s -pedantic-errors -DERROR // rdar://8827606 char *fun(void) { return "foo"; +#if defined(ERROR) #if __cplusplus >= 201103L -#ifdef ERROR // expected-error@-3 {{ISO C++11 does not allow conversion from string literal to 'char *'}} #else - // expected-warning@-5 {{ISO C++11 does not allow conversion from string literal to 'char *'}} + // expected-error@-5 {{conversion from string literal to 'char *' is deprecated}} +#endif +#elif defined(WARNING) +#if __cplusplus >= 201103L + // expected-warning@-9 {{ISO C++11 does not allow conversion from string literal to 'char *'}} +#else + // expected-warning@-11 {{conversion from string literal to 'char *' is deprecated}} #endif -#elif defined(ERROR) - // expected-error@-8 {{deprecated}} #endif } diff --git a/test/SemaObjCXX/message.mm b/test/SemaObjCXX/message.mm index 7d8520cc52..e2bdd1386f 100644 --- a/test/SemaObjCXX/message.mm +++ b/test/SemaObjCXX/message.mm @@ -1,4 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile-10.5 -verify -Wno-objc-root-class %s +// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile-10.5 -verify -Wno-objc-root-class -std=c++98 %s +// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime=macosx-fragile-10.5 -verify -Wno-objc-root-class -std=c++11 %s + @interface I1 - (int*)method; @end @@ -62,15 +65,25 @@ struct identity { // or typename-specifiers. if (false) { if (true) - return [typename identity::type method]; // expected-warning{{occurs outside of a template}} + return [typename identity::type method]; +#if __cplusplus <= 199711L + // expected-warning@-2 {{'typename' occurs outside of a template}} +#endif return [::I3 method]; } int* ip1 = {[super method]}; int* ip2 = {[::I3 method]}; - int* ip3 = {[typename identity::type method]}; // expected-warning{{occurs outside of a template}} - int* ip4 = {[typename identity::type().get() method]}; // expected-warning{{occurs outside of a template}} + int* ip3 = {[typename identity::type method]}; +#if __cplusplus <= 199711L + // expected-warning@-2 {{'typename' occurs outside of a template}} +#endif + + int* ip4 = {[typename identity::type().get() method]}; +#if __cplusplus <= 199711L + // expected-warning@-2 {{'typename' occurs outside of a template}} +#endif int array[5] = {[3] = 2}; return [super method]; } diff --git a/test/SemaTemplate/instantiate-function-2.cpp b/test/SemaTemplate/instantiate-function-2.cpp index f5089c9623..ffdb4c9144 100644 --- a/test/SemaTemplate/instantiate-function-2.cpp +++ b/test/SemaTemplate/instantiate-function-2.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 + template struct S { S() { } S(T t); @@ -46,7 +49,10 @@ namespace PR9654 { namespace AliasTagDef { template T f() { - using S = struct { // expected-warning {{C++11}} + using S = struct { +#if __cplusplus <= 199711L + // expected-warning@-2 {{alias declarations are a C++11 extension}} +#endif T g() { return T(); } diff --git a/test/SemaTemplate/instantiate-static-var.cpp b/test/SemaTemplate/instantiate-static-var.cpp index a7b3433b35..648ee4153f 100644 --- a/test/SemaTemplate/instantiate-static-var.cpp +++ b/test/SemaTemplate/instantiate-static-var.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 + template class X { public: @@ -11,7 +14,13 @@ X xi0; // expected-note{{in instantiation of template class 'X' template class Y { - static const T value = 0; // expected-warning{{in-class initializer for static data member of type 'const float' is a GNU extension}} + static const T value = 0; +#if __cplusplus <= 199711L +// expected-warning@-2 {{in-class initializer for static data member of type 'const float' is a GNU extension}} +#else +// expected-error@-4 {{in-class initializer for static data member of type 'const float' requires 'constexpr' specifier}} +// expected-note@-5 {{add 'constexpr'}} +#endif }; Y fy; // expected-note{{in instantiation of template class 'Y' requested here}} diff --git a/test/SemaTemplate/nested-name-spec-template.cpp b/test/SemaTemplate/nested-name-spec-template.cpp index 635687d4f6..78d09d13de 100644 --- a/test/SemaTemplate/nested-name-spec-template.cpp +++ b/test/SemaTemplate/nested-name-spec-template.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 namespace N { namespace M { @@ -21,8 +23,15 @@ namespace N { } M::Promote::type *ret_intptr3(int* ip) { return ip; } - M::template Promote::type *ret_intptr4(int* ip) { return ip; } // expected-warning{{'template' keyword outside of a template}} - M::template Promote pi; // expected-warning{{'template' keyword outside of a template}} + M::template Promote::type *ret_intptr4(int* ip) { return ip; } +#if __cplusplus <= 199711L + // expected-warning@-2 {{'template' keyword outside of a template}} +#endif + + M::template Promote pi; +#if __cplusplus <= 199711L + // expected-warning@-2 {{'template' keyword outside of a template}} +#endif } N::M::Promote::type *ret_intptr5(int* ip) { return ip; } diff --git a/test/SemaTemplate/overload-candidates.cpp b/test/SemaTemplate/overload-candidates.cpp index 544d897e24..c0abb5b174 100644 --- a/test/SemaTemplate/overload-candidates.cpp +++ b/test/SemaTemplate/overload-candidates.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 const T& min(const T&, const T&); // expected-note{{candidate template ignored: deduced conflicting types for parameter 'T' ('int' vs. 'long')}} @@ -94,8 +96,11 @@ namespace PR15673 { struct a_trait : std::false_type {}; template::value>::type> // expected-warning {{C++11 extension}} - // expected-note@-1 {{candidate template ignored: disabled by 'enable_if' [with T = int]}} + typename Requires = typename std::enable_if::value>::type> +#if __cplusplus <= 199711L + // expected-warning@-2 {{default template arguments for a function template are a C++11 extension}} +#endif + // expected-note@-4 {{candidate template ignored: disabled by 'enable_if' [with T = int]}} void foo() {} void bar() { foo(); } // expected-error {{no matching function for call to 'foo'}} @@ -108,7 +113,10 @@ namespace PR15673 { struct a_pony : std::enable_if::value> {}; template::type> // expected-warning {{C++11 extension}} + typename Requires = typename a_pony::type> +#if __cplusplus <= 199711L + // expected-warning@-2 {{default template arguments for a function template are a C++11 extension}} +#endif // FIXME: The source location here is poor. void baz() { } // expected-note {{candidate template ignored: substitution failure [with T = int]: no type named 'type' in 'PR15673::a_pony'}} void quux() { baz(); } // expected-error {{no matching function for call to 'baz'}} @@ -116,11 +124,17 @@ namespace PR15673 { // FIXME: This note doesn't make it clear which candidate we rejected. template - using unicorns = typename std::enable_if::value>::type; // expected-warning {{C++11 extension}} - // expected-note@-1 {{candidate template ignored: disabled by 'enable_if' [with T = int]}} + using unicorns = typename std::enable_if::value>::type; +#if __cplusplus <= 199711L + // expected-warning@-2 {{alias declarations are a C++11 extension}} +#endif + // expected-note@-4 {{candidate template ignored: disabled by 'enable_if' [with T = int]}} template > // expected-warning {{C++11 extension}} + typename Requires = unicorns > +#if __cplusplus <= 199711L + // expected-warning@-2 {{default template arguments for a function template are a C++11 extension}} +#endif void wibble() {} void wobble() { wibble(); } // expected-error {{no matching function for call to 'wibble'}} } diff --git a/test/SemaTemplate/partial-spec-instantiate.cpp b/test/SemaTemplate/partial-spec-instantiate.cpp index a93af5026d..d5ecd8c1e3 100644 --- a/test/SemaTemplate/partial-spec-instantiate.cpp +++ b/test/SemaTemplate/partial-spec-instantiate.cpp @@ -1,4 +1,6 @@ -// RUN: %clang_cc1 -fsyntax-only %s +// 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 // PR4607 template struct X {}; @@ -47,4 +49,9 @@ namespace rdar9169404 { }; X::type value; +#if __cplusplus >= 201103L + // expected-error@-2 {{non-type template argument evaluates to -1, which cannot be narrowed to type 'bool'}} +#else + // expected-no-diagnostics +#endif } diff --git a/test/SemaTemplate/temp_arg_template.cpp b/test/SemaTemplate/temp_arg_template.cpp index dec5dd37d4..4a0ed05d87 100644 --- a/test/SemaTemplate/temp_arg_template.cpp +++ b/test/SemaTemplate/temp_arg_template.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 class X> struct A; // expected-note 2{{previous template template parameter is here}} @@ -31,7 +33,10 @@ template void f(int); A *a9; // expected-error{{must be a class template}} // Evil digraph '<:' is parsed as '[', expect error. -A<::N::Z> *a10; // expected-error{{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} +A<::N::Z> *a10; +#if __cplusplus <= 199711L +// expected-error@-2 {{found '<::' after a template name which forms the digraph '<:' (aka '[') and a ':', did you mean '< ::'?}} +#endif // Do not do a digraph correction here. A<: :N::Z> *a11; // expected-error{{expected expression}} \ @@ -56,16 +61,28 @@ namespace N { } // PR12179 -template class F> // expected-warning {{variadic templates are a C++11 extension}} +template class F> +#if __cplusplus <= 199711L +// expected-warning@-2 {{variadic templates are a C++11 extension}} +#endif + struct unbox_args { typedef typename Primitive::template call x; }; -template