diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-16 14:45:37 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-16 14:45:37 +0000 |
commit | 75c3240472ba6ac2669ee72ca67eb72d4e2851fc (patch) | |
tree | 08fb6355e2578881591fdc8bac23dca750642e0b /test | |
parent | b5ea630dfd1a0d3e5c08d8959158608dd213d9aa (diff) | |
download | src-75c3240472ba6ac2669ee72ca67eb72d4e2851fc.tar.gz src-75c3240472ba6ac2669ee72ca67eb72d4e2851fc.zip |
Vendor import of clang 5.0.1 release r320880:vendor/clang/clang-release_501-r320880
Notes
Notes:
svn path=/vendor/clang/dist/; revision=326901
svn path=/vendor/clang/clang-release_501-r320880/; revision=326902; tag=vendor/clang/clang-release_501-r320880
Diffstat (limited to 'test')
-rw-r--r-- | test/SemaCXX/unused.cpp | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/test/SemaCXX/unused.cpp b/test/SemaCXX/unused.cpp index 09a179e7bb85..ba9ab2363b06 100644 --- a/test/SemaCXX/unused.cpp +++ b/test/SemaCXX/unused.cpp @@ -1,6 +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 +// RUN: %clang_cc1 -fsyntax-only -verify -Wunused %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 -Wunused %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 -Wunused %s +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wunused %s // PR4103 : Make sure we don't get a bogus unused expression warning namespace PR4103 { @@ -8,7 +9,7 @@ namespace PR4103 { char foo; }; class APSInt : public APInt { - char bar; + char bar; // expected-warning {{private field 'bar' is not used}} public: APSInt &operator=(const APSInt &RHS); }; @@ -69,3 +70,44 @@ namespace UnresolvedLookup { } }; } + +#if __cplusplus >= 201703L +namespace PR33839 { + void a() { + struct X { int a, b; } x; + auto [a, b] = x; // expected-warning {{unused variable '[a, b]'}} + auto [c, d] = x; + (void)d; + } + + template<typename T> void f() { + struct A { int n; } a[1]; + for (auto [x] : a) { + (void)x; + } + auto [y] = a[0]; // expected-warning {{unused}} + } + template<bool b> void g() { + struct A { int n; } a[1]; + for (auto [x] : a) { + if constexpr (b) + (void)x; + } + + auto [y] = a[0]; + if constexpr (b) + (void)y; // ok, even when b == false + } + template<typename T> void h() { + struct A { int n; } a[1]; + for (auto [x] : a) { // expected-warning {{unused variable '[x]'}} + } + } + void use() { + f<int>(); // expected-note {{instantiation of}} + g<true>(); + g<false>(); + h<int>(); // expected-note {{instantiation of}} + } +} +#endif |