diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-09-04 19:54:14 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-09-04 19:54:14 +0000 |
| commit | 58c743370994da37df3c6ebba76a8277af8483e0 (patch) | |
| tree | 00d4ed51761297f5bc38225ba635184165444a41 /clang/test | |
| parent | e9c4e84f8ea7a8245b1cbb44e158cf0b8d29eb28 (diff) | |
| download | bcm5719-llvm-58c743370994da37df3c6ebba76a8277af8483e0.tar.gz bcm5719-llvm-58c743370994da37df3c6ebba76a8277af8483e0.zip | |
PR10458: Finesse behaviour of C++0x features when in pre-0x mode. Accept for-range and auto with an ExtWarn, and produce a -Wc++0x-compat warning in C++98 mode when auto is used as a storage class.
llvm-svn: 139102
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/CXX/class/class.friend/p6.cpp | 2 | ||||
| -rw-r--r-- | clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp | 15 | ||||
| -rw-r--r-- | clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp | 4 | ||||
| -rw-r--r-- | clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp | 1 | ||||
| -rw-r--r-- | clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp | 13 | ||||
| -rw-r--r-- | clang/test/Misc/warning-flags.c | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/PR10458.cpp | 7 | ||||
| -rw-r--r-- | clang/test/SemaCXX/auto-cxx0x.cpp | 2 | ||||
| -rw-r--r-- | clang/test/SemaCXX/auto-cxx98.cpp | 7 | ||||
| -rw-r--r-- | clang/test/SemaCXX/class.cpp | 2 |
10 files changed, 41 insertions, 14 deletions
diff --git a/clang/test/CXX/class/class.friend/p6.cpp b/clang/test/CXX/class/class.friend/p6.cpp index bd4630e2aa9..0b173b5b3f7 100644 --- a/clang/test/CXX/class/class.friend/p6.cpp +++ b/clang/test/CXX/class/class.friend/p6.cpp @@ -3,7 +3,7 @@ class A { friend static class B; // expected-error {{'static' is invalid in friend declarations}} friend extern class C; // expected-error {{'extern' is invalid in friend declarations}} - friend auto class D; // expected-error {{'auto' is invalid in friend declarations}} + friend auto class D; // expected-warning {{incompatible with C++0x}} expected-error {{'auto' is invalid in friend declarations}} friend register class E; // expected-error {{'register' is invalid in friend declarations}} friend mutable class F; // expected-error {{'mutable' is invalid in friend declarations}} friend typedef class G; // expected-error {{'typedef' is invalid in friend declarations}} diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp index b675fb8013e..fdca88591ce 100644 --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++0x-extensions void f() { auto a = a; // expected-error{{variable 'a' declared with 'auto' type cannot appear in its own initializer}} auto *b = b; // expected-error{{variable 'b' declared with 'auto' type cannot appear in its own initializer}} @@ -39,10 +40,12 @@ void p3example() { auto x = 5; const auto *v = &x, u = 6; static auto y = 0.0; - auto int r; // expected-warning {{'auto' storage class specifier is redundant and will be removed in future releases}} - - same<decltype(x), int> xHasTypeInt; - same<decltype(v), const int*> vHasTypeConstIntPtr; - same<decltype(u), const int> uHasTypeConstInt; - same<decltype(y), double> yHasTypeDouble; + // In C++98: 'auto' storage class specifier is redundant and incompatible with C++0x + // In C++0x: 'auto' storage class specifier is not permitted in C++0x, and will not be supported in future releases + auto int r; // expected-warning {{'auto' storage class specifier}} + + same<__typeof(x), int> xHasTypeInt; + same<__typeof(v), const int*> vHasTypeConstIntPtr; + same<__typeof(u), const int> uHasTypeConstInt; + same<__typeof(y), double> yHasTypeDouble; } diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp index 8a68e4bcd79..856c707a7fa 100644 --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++0x-extensions template<typename T> struct only { @@ -19,7 +20,10 @@ void f() { for (; auto a = false; ) { } + // FIXME: support 'auto' error recovery here in pre-C++0x mode. +#if __has_feature(cxx_auto_type) new const auto (0); +#endif new (auto) (0.0); int arr[] = {1, 2, 3}; diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp index 8b4b7039847..25ce99fc10e 100644 --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p6.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++0x-extensions template<typename T> struct only { diff --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp index de87a93a2bc..9a3689f1c42 100644 --- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp +++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p7.cpp @@ -1,4 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 -Wno-c++0x-extensions void f() { auto a = 0, b = 0, c = 0; auto d = 0, e = 0.0; // expected-error {{'int' in declaration of 'd' and deduced as 'double' in declaration of 'e'}} @@ -18,6 +19,14 @@ void f() { } void g() { - auto a = 0, (*b)() -> void, c = 0; - auto d = 0, (*e)() -> void, f = 0.0; // expected-error {{'auto' deduced as 'int' in declaration of 'd' and deduced as 'double' in declaration of 'f'}} + auto a = 0, +#if __has_feature(cxx_trailing_return) + (*b)() -> void, +#endif + c = 0; + auto d = 0, // expected-error {{'auto' deduced as 'int' in declaration of 'd' and deduced as 'double' in declaration of 'f'}} +#if __has_feature(cxx_trailing_return) + (*e)() -> void, +#endif + f = 0.0; } diff --git a/clang/test/Misc/warning-flags.c b/clang/test/Misc/warning-flags.c index d24b02b27c0..50abbff6b5f 100644 --- a/clang/test/Misc/warning-flags.c +++ b/clang/test/Misc/warning-flags.c @@ -18,12 +18,12 @@ This test serves two purposes: The list of warnings below should NEVER grow. It should gradually shrink to 0. CHECK: Warnings without flags (311): -CHECK-NEXT: auto_storage_class CHECK-NEXT: backslash_newline_space CHECK-NEXT: charize_microsoft_ext CHECK-NEXT: ext_anon_param_requires_type_specifier CHECK-NEXT: ext_anonymous_struct_union_qualified CHECK-NEXT: ext_array_init_copy +CHECK-NEXT: ext_auto_storage_class CHECK-NEXT: ext_binary_literal CHECK-NEXT: ext_c1x_generic_selection CHECK-NEXT: ext_c1x_static_assert diff --git a/clang/test/SemaCXX/PR10458.cpp b/clang/test/SemaCXX/PR10458.cpp new file mode 100644 index 00000000000..e1f077aa263 --- /dev/null +++ b/clang/test/SemaCXX/PR10458.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 + +void f() { + int arr[] = { 1, 2, 3 }; + for (auto &i : arr) { // expected-warning {{'auto' type specifier is a C++0x extension}} expected-warning {{range-based for loop is a C++0x extension}} + } +} diff --git a/clang/test/SemaCXX/auto-cxx0x.cpp b/clang/test/SemaCXX/auto-cxx0x.cpp index f9246beff92..a7bb3e64e4a 100644 --- a/clang/test/SemaCXX/auto-cxx0x.cpp +++ b/clang/test/SemaCXX/auto-cxx0x.cpp @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++0x void f() { - auto int a; // expected-warning {{'auto' storage class specifier is redundant and will be removed in future releases}} + auto int a; // expected-warning {{'auto' storage class specifier is not permitted in C++0x, and will not be supported in future releases}} int auto b; // expected-error{{cannot combine with previous 'int' declaration specifier}} } diff --git a/clang/test/SemaCXX/auto-cxx98.cpp b/clang/test/SemaCXX/auto-cxx98.cpp index fe028114880..8d22469825c 100644 --- a/clang/test/SemaCXX/auto-cxx98.cpp +++ b/clang/test/SemaCXX/auto-cxx98.cpp @@ -1,5 +1,8 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++98 void f() { - auto int a; - int auto b; + auto int a; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++0x}} + int auto b; // expected-warning {{'auto' storage class specifier is redundant and incompatible with C++0x}} + auto c; // expected-warning {{C++0x extension}} expected-error {{requires an initializer}} + static auto d = 0; // expected-warning {{C++0x extension}} + auto static e = 0; // expected-warning {{C++0x extension}} } diff --git a/clang/test/SemaCXX/class.cpp b/clang/test/SemaCXX/class.cpp index 44fa0ce7ec9..fd2d0b388a7 100644 --- a/clang/test/SemaCXX/class.cpp +++ b/clang/test/SemaCXX/class.cpp @@ -1,7 +1,7 @@ // RUN: %clang_cc1 -fsyntax-only -verify %s class C { public: - auto int errx; // expected-error {{error: storage class specified for a member declaration}} + auto int errx; // expected-error {{error: storage class specified for a member declaration}} expected-warning {{'auto' storage class specifier is redundant}} register int erry; // expected-error {{error: storage class specified for a member declaration}} extern int errz; // expected-error {{error: storage class specified for a member declaration}} |

