From fb42f4c44adc1e2ac25c1305e77d53e735012b77 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Mon, 2 May 2016 19:15:48 +0000 Subject: [PATCH] Void cast runtime-unused variables. Patch from STL@microsoft.com llvm-svn: 268284 --- libcxx/test/std/depr/depr.c.headers/setjmp_h.pass.cpp | 1 + libcxx/test/std/depr/depr.c.headers/stdio_h.pass.cpp | 8 +++++++- .../input.output/file.streams/c.files/cstdio.pass.cpp | 5 +++++ .../ostream.inserters.arithmetic/minus1.pass.cpp | 2 +- .../bidirectional_iterator_tag.pass.cpp | 1 + .../std.iterator.tags/forward_iterator_tag.pass.cpp | 1 + .../std.iterator.tags/input_iterator_tag.pass.cpp | 1 + .../std.iterator.tags/output_iterator_tag.pass.cpp | 1 + .../random_access_iterator_tag.pass.cpp | 1 + .../except.nested/throw_with_nested.pass.cpp | 2 +- .../propagation/current_exception.pass.cpp | 4 ++-- .../language.support/support.runtime/csetjmp.pass.cpp | 1 + .../language.support/support.runtime/ctime.pass.cpp | 7 ++++++- .../test/std/localization/c.locales/clocale.pass.cpp | 1 + .../facet.num.put.members/put_long_double.pass.cpp | 3 +-- .../test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp | 2 ++ .../test/std/numerics/rand/rand.device/eval.pass.cpp | 2 +- libcxx/test/std/re/re.alg/re.alg.search/grep.pass.cpp | 2 +- libcxx/test/std/strings/c.strings/cwchar.pass.cpp | 10 ++++++++++ .../allocator_pointers.pass.cpp | 10 ++++++++-- .../default.allocator/allocator_pointers.pass.cpp | 10 ++++++++-- .../test/std/utilities/time/date.time/ctime.pass.cpp | 6 +++++- .../std/utilities/utility/forward/forward.pass.cpp | 3 +++ 23 files changed, 69 insertions(+), 15 deletions(-) diff --git a/libcxx/test/std/depr/depr.c.headers/setjmp_h.pass.cpp b/libcxx/test/std/depr/depr.c.headers/setjmp_h.pass.cpp index 9bc35b747493..9663d8892ac5 100644 --- a/libcxx/test/std/depr/depr.c.headers/setjmp_h.pass.cpp +++ b/libcxx/test/std/depr/depr.c.headers/setjmp_h.pass.cpp @@ -19,6 +19,7 @@ int main() { jmp_buf jb; + ((void)jb); // Prevent unused warning static_assert((std::is_same::value), "std::is_same::value"); } diff --git a/libcxx/test/std/depr/depr.c.headers/stdio_h.pass.cpp b/libcxx/test/std/depr/depr.c.headers/stdio_h.pass.cpp index 0ea105dd3d3c..9071f80590b9 100644 --- a/libcxx/test/std/depr/depr.c.headers/stdio_h.pass.cpp +++ b/libcxx/test/std/depr/depr.c.headers/stdio_h.pass.cpp @@ -108,10 +108,16 @@ int main() { FILE* fp = 0; fpos_t fpos = {0}; - size_t s = 0; ((void)s); + size_t s = 0; char* cp = 0; char arr[] = {'a', 'b'}; va_list va; + ((void)fp); // Prevent unused warning + ((void)fpos); // Prevent unused warning + ((void)s); // Prevent unused warning + ((void)cp); // Prevent unused warning + ((void)arr); // Prevent unused warning + ((void)va); // Prevent unused warning static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); diff --git a/libcxx/test/std/input.output/file.streams/c.files/cstdio.pass.cpp b/libcxx/test/std/input.output/file.streams/c.files/cstdio.pass.cpp index 56beb58c3a38..c42e205fd357 100644 --- a/libcxx/test/std/input.output/file.streams/c.files/cstdio.pass.cpp +++ b/libcxx/test/std/input.output/file.streams/c.files/cstdio.pass.cpp @@ -91,6 +91,11 @@ int main() std::size_t s = 0; char* cp = 0; std::va_list va; + ((void)fp); // Prevent unused warning + ((void)fpos); // Prevent unused warning + ((void)s); // Prevent unused warning + ((void)cp); // Prevent unused warning + ((void)va); // Prevent unused warning static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); diff --git a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp b/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp index c9b617253241..47e257a18684 100644 --- a/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp +++ b/libcxx/test/std/input.output/iostream.format/output.streams/ostream.formatted/ostream.inserters.arithmetic/minus1.pass.cpp @@ -56,7 +56,7 @@ void test_hex(const char *expected) assert(str == expected); } -int main(int argc, char* argv[]) +int main() { test_octal( "177777"); diff --git a/libcxx/test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp b/libcxx/test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp index 0f368c3b765f..ecda1d146949 100644 --- a/libcxx/test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp +++ b/libcxx/test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp @@ -17,6 +17,7 @@ int main() { std::bidirectional_iterator_tag tag; + ((void)tag); // Prevent unused warning static_assert((std::is_base_of::value), ""); static_assert((!std::is_base_of::value), ""); static_assert((!std::is_base_of::value), ""); } diff --git a/libcxx/test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp b/libcxx/test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp index 7f7f66a98f4a..e315b2724f82 100644 --- a/libcxx/test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp +++ b/libcxx/test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp @@ -17,6 +17,7 @@ int main() { std::output_iterator_tag tag; + ((void)tag); // Prevent unused warning static_assert((!std::is_base_of::value), ""); } diff --git a/libcxx/test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp b/libcxx/test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp index 04f830bc3109..f16a3b74c53f 100644 --- a/libcxx/test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp +++ b/libcxx/test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp @@ -17,6 +17,7 @@ int main() { std::random_access_iterator_tag tag; + ((void)tag); // Prevent unused warning static_assert((std::is_base_of::value), ""); static_assert((!std::is_base_of::value), "std::is_same::value"); } diff --git a/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp b/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp index 03a0aa4d6966..5f2948605185 100644 --- a/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp +++ b/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp @@ -23,10 +23,13 @@ int main() { std::clock_t c = 0; - ((void)c); std::size_t s = 0; std::time_t t = 0; std::tm tm = {0}; + ((void)c); // Prevent unused warning + ((void)s); // Prevent unused warning + ((void)t); // Prevent unused warning + ((void)tm); // Prevent unused warning static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); @@ -39,5 +42,7 @@ int main() #endif char* c1 = 0; const char* c2 = 0; + ((void)c1); // Prevent unused warning + ((void)c2); // Prevent unused warning static_assert((std::is_same::value), ""); } diff --git a/libcxx/test/std/localization/c.locales/clocale.pass.cpp b/libcxx/test/std/localization/c.locales/clocale.pass.cpp index a90725bfa367..534213495cd9 100644 --- a/libcxx/test/std/localization/c.locales/clocale.pass.cpp +++ b/libcxx/test/std/localization/c.locales/clocale.pass.cpp @@ -47,6 +47,7 @@ int main() { std::lconv lc; + ((void)lc); // Prevent unused warning #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS static_assert((std::is_same::value), ""); #endif diff --git a/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp b/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp index ec5874b44139..a52c2c7c1533 100644 --- a/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp +++ b/libcxx/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp @@ -24415,7 +24415,6 @@ void test11() void test12() { - char str[200]; output_iterator iter; std::locale lc = std::locale::classic(); std::locale lg(lc, new my_numpunct); @@ -24423,6 +24422,7 @@ void test12() // This test is failing on FreeBSD, possibly due to different representations // of the floating point numbers. const my_facet f(1); + char str[200]; { long double v = 1234567890.125; std::ios ios(0); @@ -26221,7 +26221,6 @@ int main() test10(); test11(); test12(); - char str[200]; output_iterator iter; std::locale lc = std::locale::classic(); std::locale lg(lc, new my_numpunct); diff --git a/libcxx/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp b/libcxx/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp index fcf075a36e1a..f2bf6433ceb4 100644 --- a/libcxx/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp +++ b/libcxx/test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp @@ -62,6 +62,8 @@ int main() { std::fenv_t fenv; std::fexcept_t fex; + ((void)fenv); // Prevent unused warning + ((void)fex); // Prevent unused warning static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); diff --git a/libcxx/test/std/numerics/rand/rand.device/eval.pass.cpp b/libcxx/test/std/numerics/rand/rand.device/eval.pass.cpp index ed5361fbde75..e319e0f4eed3 100644 --- a/libcxx/test/std/numerics/rand/rand.device/eval.pass.cpp +++ b/libcxx/test/std/numerics/rand/rand.device/eval.pass.cpp @@ -30,7 +30,7 @@ int main() r(); assert(false); } - catch (const std::system_error& e) + catch (const std::system_error&) { } } diff --git a/libcxx/test/std/re/re.alg/re.alg.search/grep.pass.cpp b/libcxx/test/std/re/re.alg/re.alg.search/grep.pass.cpp index 9d74c2417d2d..197af8d2cd0a 100644 --- a/libcxx/test/std/re/re.alg/re.alg.search/grep.pass.cpp +++ b/libcxx/test/std/re/re.alg/re.alg.search/grep.pass.cpp @@ -35,7 +35,7 @@ extern "C" void LLVMFuzzerTestOneInput(const char *data) std::regex re(s, flag); std::regex_match(s, re); } - catch (std::regex_error &ex) {} + catch (std::regex_error &) {} } } diff --git a/libcxx/test/std/strings/c.strings/cwchar.pass.cpp b/libcxx/test/std/strings/c.strings/cwchar.pass.cpp index fc4228237ad0..2b7c3c465f6d 100644 --- a/libcxx/test/std/strings/c.strings/cwchar.pass.cpp +++ b/libcxx/test/std/strings/c.strings/cwchar.pass.cpp @@ -40,6 +40,16 @@ int main() char* ns = 0; wchar_t* ws = 0; + + ((void)mb); // Prevent unused warning + ((void)s); // Prevent unused warning + ((void)tm); // Prevent unused warning + ((void)w); // Prevent unused warning + ((void)fp); // Prevent unused warning + ((void)va); // Prevent unused warning + ((void)ns); // Prevent unused warning + ((void)ws); // Prevent unused warning + static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); diff --git a/libcxx/test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp b/libcxx/test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp index e165d9836db0..bc5de61d8019 100644 --- a/libcxx/test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp +++ b/libcxx/test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp @@ -37,7 +37,10 @@ void test_pointer() { typename std::allocator_traits::pointer vp; typename std::allocator_traits::const_pointer cvp; - + + ((void)vp); // Prevent unused warning + ((void)cvp); // Prevent unused warning + static_assert(std::is_same::value, ""); static_assert(std::is_same::value, ""); static_assert(std::is_same vp)>::value, ""); @@ -71,7 +74,10 @@ void test_void_pointer() { typename std::allocator_traits::void_pointer vp; typename std::allocator_traits::const_void_pointer cvp; - + + ((void)vp); // Prevent unused warning + ((void)cvp); // Prevent unused warning + static_assert(std::is_same::value, ""); static_assert(std::is_same::value, ""); static_assert(std::is_same vp)>::value, ""); diff --git a/libcxx/test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp b/libcxx/test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp index 5a8f7a28a042..588227f0a49d 100644 --- a/libcxx/test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp +++ b/libcxx/test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp @@ -36,7 +36,10 @@ void test_pointer() { typename std::allocator_traits::pointer vp; typename std::allocator_traits::const_pointer cvp; - + + ((void)vp); // Prevent unused warning + ((void)cvp); // Prevent unused warning + static_assert(std::is_same::value, ""); static_assert(std::is_same::value, ""); static_assert(std::is_same vp)>::value, ""); @@ -70,7 +73,10 @@ void test_void_pointer() { typename std::allocator_traits::void_pointer vp; typename std::allocator_traits::const_void_pointer cvp; - + + ((void)vp); // Prevent unused warning + ((void)cvp); // Prevent unused warning + static_assert(std::is_same::value, ""); static_assert(std::is_same::value, ""); static_assert(std::is_same vp)>::value, ""); diff --git a/libcxx/test/std/utilities/time/date.time/ctime.pass.cpp b/libcxx/test/std/utilities/time/date.time/ctime.pass.cpp index d0a838e0c271..b762d273de98 100644 --- a/libcxx/test/std/utilities/time/date.time/ctime.pass.cpp +++ b/libcxx/test/std/utilities/time/date.time/ctime.pass.cpp @@ -21,11 +21,15 @@ int main() { std::clock_t c = 0; - ((void)c); // avoid unused warning std::size_t s = 0; std::time_t t = 0; std::tm tm = {0}; char str[3]; + ((void)c); // Prevent unused warning + ((void)s); // Prevent unused warning + ((void)t); // Prevent unused warning + ((void)tm); // Prevent unused warning + ((void)str); // Prevent unused warning static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); diff --git a/libcxx/test/std/utilities/utility/forward/forward.pass.cpp b/libcxx/test/std/utilities/utility/forward/forward.pass.cpp index 357b36fafa96..94575485df04 100644 --- a/libcxx/test/std/utilities/utility/forward/forward.pass.cpp +++ b/libcxx/test/std/utilities/utility/forward/forward.pass.cpp @@ -39,6 +39,9 @@ int main() A a; const A ca = A(); + ((void)a); // Prevent unused warning + ((void)ca); // Prevent unused warning + #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES static_assert(sizeof(test(std::forward(a))) == 1, ""); static_assert(sizeof(test(std::forward(a))) == 4, "");