From 5fd308971d84277e2107c2e7ac4a29386d2e34c1 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Sat, 18 Jul 2015 21:17:16 +0000 Subject: [PATCH] Fix warnings in test/std/language.support llvm-svn: 242624 --- libcxx/test/libcxx/compiler.py | 11 +++++++++++ libcxx/test/libcxx/test/config.py | 7 +++---- .../alloc.errors/new.handler/new_handler.pass.cpp | 4 ++++ .../new.delete/new.delete.array/new_array.pass.cpp | 3 ++- .../new.delete/new.delete.single/new.pass.cpp | 1 + .../terminate.handler/terminate_handler.pass.cpp | 4 ++++ .../language.support/support.runtime/csignal.pass.cpp | 3 ++- .../language.support/support.runtime/cstdarg.pass.cpp | 1 + .../language.support/support.runtime/cstdlib.pass.cpp | 18 +++++++++++++++--- .../language.support/support.runtime/ctime.pass.cpp | 1 + 10 files changed, 44 insertions(+), 9 deletions(-) diff --git a/libcxx/test/libcxx/compiler.py b/libcxx/test/libcxx/compiler.py index 7afbed4..24ac431 100644 --- a/libcxx/test/libcxx/compiler.py +++ b/libcxx/test/libcxx/compiler.py @@ -150,3 +150,14 @@ class CXXCompiler(object): cmd, out, err, rc = self.compile(os.devnull, out=os.devnull, flags=flags) return rc == 0 + + def addCompileFlagIfSupported(self, flag): + if isinstance(flag, list): + flags = list(flag) + else: + flags = [flag] + if self.hasCompileFlag(flags): + self.compile_flags += flags + return True + else: + return False diff --git a/libcxx/test/libcxx/test/config.py b/libcxx/test/libcxx/test/config.py index 09fbf66..8e421f3 100644 --- a/libcxx/test/libcxx/test/config.py +++ b/libcxx/test/libcxx/test/config.py @@ -570,10 +570,9 @@ class Configuration(object): def configure_warnings(self): enable_warnings = self.get_lit_bool('enable_warnings', False) if enable_warnings: - self.cxx.compile_flags += ['-Wsystem-headers', '-Wall', '-Werror'] - if ('clang' in self.config.available_features or - 'apple-clang' in self.config.available_features): - self.cxx.compile_flags += ['-Wno-user-defined-literals'] + self.cxx.compile_flags += ['-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER', + '-Wall', '-Werror'] + self.cxx.addCompileFlagIfSupported('-Wno-user-defined-literals') def configure_sanitizer(self): san = self.get_lit_conf('use_sanitizer', '').strip() diff --git a/libcxx/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp b/libcxx/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp index 6b799a3..38e040c 100644 --- a/libcxx/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp +++ b/libcxx/test/std/language.support/support.dynamic/alloc.errors/new.handler/new_handler.pass.cpp @@ -10,10 +10,14 @@ // test new_handler #include +#include +#include void f() {} int main() { + static_assert(std::is_same::value, ""); std::new_handler p = f; + assert(p == &f); } diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp index 5a87c07..a1a3035 100644 --- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp +++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array.pass.cpp @@ -38,7 +38,8 @@ int main() std::set_new_handler(new_handler); try { - void*volatile vp = operator new[] (std::numeric_limits::max()); + void* volatile vp = operator new[] (std::numeric_limits::max()); + ((void)vp); assert(false); } catch (std::bad_alloc&) diff --git a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp index 58aa3f2..5dc9f71 100644 --- a/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp +++ b/libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/new.pass.cpp @@ -39,6 +39,7 @@ int main() try { void* vp = operator new (std::numeric_limits::max()); + ((void)vp); assert(false); } catch (std::bad_alloc&) diff --git a/libcxx/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp b/libcxx/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp index 232ce0a5..46e2126 100644 --- a/libcxx/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp +++ b/libcxx/test/std/language.support/support.exception/exception.terminate/terminate.handler/terminate_handler.pass.cpp @@ -10,10 +10,14 @@ // test terminate_handler #include +#include +#include void f() {} int main() { + static_assert(std::is_same::value, ""); std::terminate_handler p = f; + assert(p == &f); } diff --git a/libcxx/test/std/language.support/support.runtime/csignal.pass.cpp b/libcxx/test/std/language.support/support.runtime/csignal.pass.cpp index 717347d..a42363f 100644 --- a/libcxx/test/std/language.support/support.runtime/csignal.pass.cpp +++ b/libcxx/test/std/language.support/support.runtime/csignal.pass.cpp @@ -50,7 +50,8 @@ int main() { - std::sig_atomic_t sig; + std::sig_atomic_t sig = 0; + ((void)sig); typedef void (*func)(int); static_assert((std::is_same::value), ""); static_assert((std::is_same::value), ""); diff --git a/libcxx/test/std/language.support/support.runtime/cstdarg.pass.cpp b/libcxx/test/std/language.support/support.runtime/cstdarg.pass.cpp index 059ad2f..9d6f610 100644 --- a/libcxx/test/std/language.support/support.runtime/cstdarg.pass.cpp +++ b/libcxx/test/std/language.support/support.runtime/cstdarg.pass.cpp @@ -32,4 +32,5 @@ int main() { std::va_list va; + ((void)va); } diff --git a/libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp b/libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp index 0739491..d1b335c 100644 --- a/libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp +++ b/libcxx/test/std/language.support/support.runtime/cstdlib.pass.cpp @@ -11,6 +11,7 @@ #include #include +#include #ifndef EXIT_FAILURE #error EXIT_FAILURE not defined @@ -32,12 +33,23 @@ #error RAND_MAX not defined #endif +template +void test_div_struct() { + TestType obj; + static_assert(sizeof(obj) >= sizeof(IntType) * 2, ""); // >= to account for alignment. + static_assert(std::is_same::value, ""); + static_assert(std::is_same::value, ""); + ((void) obj); +}; + int main() { std::size_t s = 0; - std::div_t d; - std::ldiv_t ld; - std::lldiv_t lld; + ((void)s); + static_assert(std::is_same::value, ""); + test_div_struct(); + test_div_struct(); + test_div_struct(); char** endptr = 0; static_assert((std::is_same::value), ""); static_assert((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 8c5d281..03a0aa4 100644 --- a/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp +++ b/libcxx/test/std/language.support/support.runtime/ctime.pass.cpp @@ -23,6 +23,7 @@ int main() { std::clock_t c = 0; + ((void)c); std::size_t s = 0; std::time_t t = 0; std::tm tm = {0}; -- 2.7.4