diff options
Diffstat (limited to 'clang/test/SemaCXX')
| -rw-r--r-- | clang/test/SemaCXX/decl-expr-ambiguity.cpp | 5 | ||||
| -rw-r--r-- | clang/test/SemaCXX/overload-call.cpp | 45 | ||||
| -rw-r--r-- | clang/test/SemaCXX/pragma-init_seg.cpp | 7 | ||||
| -rw-r--r-- | clang/test/SemaCXX/typo-correction-delayed.cpp | 8 | ||||
| -rw-r--r-- | clang/test/SemaCXX/unknown-type-name.cpp | 8 | ||||
| -rw-r--r-- | clang/test/SemaCXX/writable-strings-deprecated.cpp | 30 |
6 files changed, 81 insertions, 22 deletions
diff --git a/clang/test/SemaCXX/decl-expr-ambiguity.cpp b/clang/test/SemaCXX/decl-expr-ambiguity.cpp index 6abfb2f3287..1b1f7dc8a70 100644 --- a/clang/test/SemaCXX/decl-expr-ambiguity.cpp +++ b/clang/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/clang/test/SemaCXX/overload-call.cpp b/clang/test/SemaCXX/overload-call.cpp index 7c6fe2b7e4e..3d286a94a04 100644 --- a/clang/test/SemaCXX/overload-call.cpp +++ b/clang/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/clang/test/SemaCXX/pragma-init_seg.cpp b/clang/test/SemaCXX/pragma-init_seg.cpp index e18d0e6814a..1b22939f18e 100644 --- a/clang/test/SemaCXX/pragma-init_seg.cpp +++ b/clang/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/clang/test/SemaCXX/typo-correction-delayed.cpp b/clang/test/SemaCXX/typo-correction-delayed.cpp index 121863d172b..610d4397138 100644 --- a/clang/test/SemaCXX/typo-correction-delayed.cpp +++ b/clang/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/clang/test/SemaCXX/unknown-type-name.cpp b/clang/test/SemaCXX/unknown-type-name.cpp index 9d28c310ed9..2a9748e3ab6 100644 --- a/clang/test/SemaCXX/unknown-type-name.cpp +++ b/clang/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<typename T> int h(T::type x, char); // expected-error{{missing 'typenam template<typename T> int junk1(T::junk); // expected-warning{{variable templates are a C++14 extension}} template<typename T> int junk2(T::junk) throw(); // expected-error{{missing 'typename'}} -template<typename T> int junk3(T::junk) = delete; // expected-error{{missing 'typename'}} expected-warning{{C++11}} +template<typename T> 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<typename T> 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/clang/test/SemaCXX/writable-strings-deprecated.cpp b/clang/test/SemaCXX/writable-strings-deprecated.cpp index f9258334980..7de11b59dd1 100644 --- a/clang/test/SemaCXX/writable-strings-deprecated.cpp +++ b/clang/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 } |

