STL_MSFT created this revision. STL_MSFT added reviewers: mclow.lists, EricWF. STL_MSFT added a subscriber: cfe-commits.
[libc++] Void-cast runtime-unused variables. Also, remove unused names in exception handlers and remove an unused array. Fixes MSVC "warning C4101: unreferenced local variable". http://reviews.llvm.org/D19625 Files: test/std/depr/depr.c.headers/setjmp_h.pass.cpp test/std/depr/depr.c.headers/stdio_h.pass.cpp test/std/input.output/file.streams/c.files/cstdio.pass.cpp test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp test/std/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp test/std/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp test/std/language.support/support.exception/propagation/current_exception.pass.cpp test/std/language.support/support.runtime/csetjmp.pass.cpp test/std/language.support/support.runtime/ctime.pass.cpp test/std/localization/c.locales/clocale.pass.cpp test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp test/std/numerics/rand/rand.device/eval.pass.cpp test/std/re/re.alg/re.alg.search/grep.pass.cpp test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp test/std/utilities/time/date.time/ctime.pass.cpp test/std/utilities/utility/forward/forward.pass.cpp
Index: test/std/utilities/utility/forward/forward.pass.cpp =================================================================== --- test/std/utilities/utility/forward/forward.pass.cpp +++ test/std/utilities/utility/forward/forward.pass.cpp @@ -39,6 +39,9 @@ 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&>(a))) == 1, ""); static_assert(sizeof(test(std::forward<A>(a))) == 4, ""); Index: test/std/utilities/time/date.time/ctime.pass.cpp =================================================================== --- test/std/utilities/time/date.time/ctime.pass.cpp +++ 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<decltype(std::clock()), std::clock_t>::value), ""); static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), ""); static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), ""); Index: test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp =================================================================== --- test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp +++ test/std/utilities/memory/default.allocator/allocator_pointers.pass.cpp @@ -36,7 +36,10 @@ { typename std::allocator_traits<Alloc>::pointer vp; typename std::allocator_traits<Alloc>::const_pointer cvp; - + + ((void)vp); // Prevent unused warning + ((void)cvp); // Prevent unused warning + static_assert(std::is_same<bool, decltype( vp == vp)>::value, ""); static_assert(std::is_same<bool, decltype( vp != vp)>::value, ""); static_assert(std::is_same<bool, decltype( vp > vp)>::value, ""); @@ -70,7 +73,10 @@ { typename std::allocator_traits<Alloc>::void_pointer vp; typename std::allocator_traits<Alloc>::const_void_pointer cvp; - + + ((void)vp); // Prevent unused warning + ((void)cvp); // Prevent unused warning + static_assert(std::is_same<bool, decltype( vp == vp)>::value, ""); static_assert(std::is_same<bool, decltype( vp != vp)>::value, ""); static_assert(std::is_same<bool, decltype( vp > vp)>::value, ""); Index: test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp =================================================================== --- test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp +++ test/std/utilities/allocator.adaptor/allocator.adaptor.types/allocator_pointers.pass.cpp @@ -37,7 +37,10 @@ { typename std::allocator_traits<Alloc>::pointer vp; typename std::allocator_traits<Alloc>::const_pointer cvp; - + + ((void)vp); // Prevent unused warning + ((void)cvp); // Prevent unused warning + static_assert(std::is_same<bool, decltype( vp == vp)>::value, ""); static_assert(std::is_same<bool, decltype( vp != vp)>::value, ""); static_assert(std::is_same<bool, decltype( vp > vp)>::value, ""); @@ -71,7 +74,10 @@ { typename std::allocator_traits<Alloc>::void_pointer vp; typename std::allocator_traits<Alloc>::const_void_pointer cvp; - + + ((void)vp); // Prevent unused warning + ((void)cvp); // Prevent unused warning + static_assert(std::is_same<bool, decltype( vp == vp)>::value, ""); static_assert(std::is_same<bool, decltype( vp != vp)>::value, ""); static_assert(std::is_same<bool, decltype( vp > vp)>::value, ""); Index: test/std/re/re.alg/re.alg.search/grep.pass.cpp =================================================================== --- test/std/re/re.alg/re.alg.search/grep.pass.cpp +++ test/std/re/re.alg/re.alg.search/grep.pass.cpp @@ -35,7 +35,7 @@ std::regex re(s, flag); std::regex_match(s, re); } - catch (std::regex_error &ex) {} + catch (std::regex_error &) {} } } Index: test/std/numerics/rand/rand.device/eval.pass.cpp =================================================================== --- test/std/numerics/rand/rand.device/eval.pass.cpp +++ test/std/numerics/rand/rand.device/eval.pass.cpp @@ -30,7 +30,7 @@ r(); assert(false); } - catch (const std::system_error& e) + catch (const std::system_error&) { } } Index: test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp =================================================================== --- test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp +++ test/std/numerics/cfenv/cfenv.syn/cfenv.pass.cpp @@ -62,6 +62,8 @@ { std::fenv_t fenv; std::fexcept_t fex; + ((void)fenv); // Prevent unused warning + ((void)fex); // Prevent unused warning static_assert((std::is_same<decltype(std::feclearexcept(0)), int>::value), ""); static_assert((std::is_same<decltype(std::fegetexceptflag(&fex, 0)), int>::value), ""); static_assert((std::is_same<decltype(std::feraiseexcept(0)), int>::value), ""); Index: test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp =================================================================== --- test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp +++ test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp @@ -24419,6 +24419,7 @@ output_iterator<char*> iter; std::locale lc = std::locale::classic(); std::locale lg(lc, new my_numpunct); + ((void)str); // Prevent unused warning #ifdef __APPLE__ // This test is failing on FreeBSD, possibly due to different representations // of the floating point numbers. @@ -26221,7 +26222,6 @@ test10(); test11(); test12(); - char str[200]; output_iterator<char*> iter; std::locale lc = std::locale::classic(); std::locale lg(lc, new my_numpunct); Index: test/std/localization/c.locales/clocale.pass.cpp =================================================================== --- test/std/localization/c.locales/clocale.pass.cpp +++ 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<decltype(std::setlocale(0, "")), char*>::value), ""); #endif Index: test/std/language.support/support.runtime/ctime.pass.cpp =================================================================== --- test/std/language.support/support.runtime/ctime.pass.cpp +++ 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<decltype(std::clock()), std::clock_t>::value), ""); static_assert((std::is_same<decltype(std::difftime(t,t)), double>::value), ""); static_assert((std::is_same<decltype(std::mktime(&tm)), std::time_t>::value), ""); @@ -39,5 +42,7 @@ #endif char* c1 = 0; const char* c2 = 0; + ((void)c1); // Prevent unused warning + ((void)c2); // Prevent unused warning static_assert((std::is_same<decltype(std::strftime(c1,s,c2,&tm)), std::size_t>::value), ""); } Index: test/std/language.support/support.runtime/csetjmp.pass.cpp =================================================================== --- test/std/language.support/support.runtime/csetjmp.pass.cpp +++ test/std/language.support/support.runtime/csetjmp.pass.cpp @@ -19,6 +19,7 @@ int main() { std::jmp_buf jb; + ((void)jb); // Prevent unused warning static_assert((std::is_same<decltype(std::longjmp(jb, 0)), void>::value), "std::is_same<decltype(std::longjmp(jb, 0)), void>::value"); } Index: test/std/language.support/support.exception/propagation/current_exception.pass.cpp =================================================================== --- test/std/language.support/support.exception/propagation/current_exception.pass.cpp +++ test/std/language.support/support.exception/propagation/current_exception.pass.cpp @@ -74,7 +74,7 @@ throw A(); assert(false); } - catch (A& a) + catch (A&) { std::exception_ptr p = std::current_exception(); assert(A::constructed == 1); @@ -94,7 +94,7 @@ throw A(); assert(false); } - catch (A a) + catch (A) { std::exception_ptr p = std::current_exception(); assert(A::constructed == 2); Index: test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp =================================================================== --- test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp +++ test/std/language.support/support.exception/except.nested/throw_with_nested.pass.cpp @@ -112,7 +112,7 @@ std::throw_with_nested(Final()); assert(false); } - catch (const Final &f) + catch (const Final &) { } } Index: test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp =================================================================== --- test/std/iterators/iterator.primitives/std.iterator.tags/random_access_iterator_tag.pass.cpp +++ 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<std::bidirectional_iterator_tag, std::random_access_iterator_tag>::value), ""); static_assert((!std::is_base_of<std::output_iterator_tag, Index: test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp =================================================================== --- test/std/iterators/iterator.primitives/std.iterator.tags/output_iterator_tag.pass.cpp +++ 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<std::input_iterator_tag, std::output_iterator_tag>::value), ""); } Index: test/std/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp =================================================================== --- test/std/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp +++ test/std/iterators/iterator.primitives/std.iterator.tags/input_iterator_tag.pass.cpp @@ -17,6 +17,7 @@ int main() { std::input_iterator_tag tag; + ((void)tag); // Prevent unused warning static_assert((!std::is_base_of<std::output_iterator_tag, std::input_iterator_tag>::value), ""); } Index: test/std/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp =================================================================== --- test/std/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp +++ test/std/iterators/iterator.primitives/std.iterator.tags/forward_iterator_tag.pass.cpp @@ -17,6 +17,7 @@ int main() { std::forward_iterator_tag tag; + ((void)tag); // Prevent unused warning static_assert((std::is_base_of<std::input_iterator_tag, std::forward_iterator_tag>::value), ""); static_assert((!std::is_base_of<std::output_iterator_tag, Index: test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp =================================================================== --- test/std/iterators/iterator.primitives/std.iterator.tags/bidirectional_iterator_tag.pass.cpp +++ 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<std::forward_iterator_tag, std::bidirectional_iterator_tag>::value), ""); static_assert((!std::is_base_of<std::output_iterator_tag, Index: test/std/input.output/file.streams/c.files/cstdio.pass.cpp =================================================================== --- test/std/input.output/file.streams/c.files/cstdio.pass.cpp +++ test/std/input.output/file.streams/c.files/cstdio.pass.cpp @@ -91,6 +91,11 @@ 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<decltype(std::fclose(fp)), int>::value), ""); static_assert((std::is_same<decltype(std::fflush(fp)), int>::value), ""); static_assert((std::is_same<decltype(std::setbuf(fp,cp)), void>::value), ""); Index: test/std/depr/depr.c.headers/stdio_h.pass.cpp =================================================================== --- test/std/depr/depr.c.headers/stdio_h.pass.cpp +++ test/std/depr/depr.c.headers/stdio_h.pass.cpp @@ -108,10 +108,16 @@ { 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<decltype(remove("")), int>::value), ""); static_assert((std::is_same<decltype(rename("","")), int>::value), ""); static_assert((std::is_same<decltype(tmpfile()), FILE*>::value), ""); Index: test/std/depr/depr.c.headers/setjmp_h.pass.cpp =================================================================== --- test/std/depr/depr.c.headers/setjmp_h.pass.cpp +++ 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<decltype(longjmp(jb, 0)), void>::value), "std::is_same<decltype(longjmp(jb, 0)), void>::value"); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits