Fix warnings in test/std/language.support
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@242624 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
692177d022
commit
7b86ce5cc4
@ -150,3 +150,14 @@ class CXXCompiler(object):
|
|||||||
cmd, out, err, rc = self.compile(os.devnull, out=os.devnull,
|
cmd, out, err, rc = self.compile(os.devnull, out=os.devnull,
|
||||||
flags=flags)
|
flags=flags)
|
||||||
return rc == 0
|
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
|
||||||
|
@ -570,10 +570,9 @@ class Configuration(object):
|
|||||||
def configure_warnings(self):
|
def configure_warnings(self):
|
||||||
enable_warnings = self.get_lit_bool('enable_warnings', False)
|
enable_warnings = self.get_lit_bool('enable_warnings', False)
|
||||||
if enable_warnings:
|
if enable_warnings:
|
||||||
self.cxx.compile_flags += ['-Wsystem-headers', '-Wall', '-Werror']
|
self.cxx.compile_flags += ['-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER',
|
||||||
if ('clang' in self.config.available_features or
|
'-Wall', '-Werror']
|
||||||
'apple-clang' in self.config.available_features):
|
self.cxx.addCompileFlagIfSupported('-Wno-user-defined-literals')
|
||||||
self.cxx.compile_flags += ['-Wno-user-defined-literals']
|
|
||||||
|
|
||||||
def configure_sanitizer(self):
|
def configure_sanitizer(self):
|
||||||
san = self.get_lit_conf('use_sanitizer', '').strip()
|
san = self.get_lit_conf('use_sanitizer', '').strip()
|
||||||
|
@ -10,10 +10,14 @@
|
|||||||
// test new_handler
|
// test new_handler
|
||||||
|
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
void f() {}
|
void f() {}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
static_assert(std::is_same<std::new_handler, void(*)()>::value, "");
|
||||||
std::new_handler p = f;
|
std::new_handler p = f;
|
||||||
|
assert(p == &f);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,8 @@ int main()
|
|||||||
std::set_new_handler(new_handler);
|
std::set_new_handler(new_handler);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
void*volatile vp = operator new[] (std::numeric_limits<std::size_t>::max());
|
void* volatile vp = operator new[] (std::numeric_limits<std::size_t>::max());
|
||||||
|
((void)vp);
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
catch (std::bad_alloc&)
|
catch (std::bad_alloc&)
|
||||||
|
@ -39,6 +39,7 @@ int main()
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
void* vp = operator new (std::numeric_limits<std::size_t>::max());
|
void* vp = operator new (std::numeric_limits<std::size_t>::max());
|
||||||
|
((void)vp);
|
||||||
assert(false);
|
assert(false);
|
||||||
}
|
}
|
||||||
catch (std::bad_alloc&)
|
catch (std::bad_alloc&)
|
||||||
|
@ -10,10 +10,14 @@
|
|||||||
// test terminate_handler
|
// test terminate_handler
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
void f() {}
|
void f() {}
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
static_assert(std::is_same<std::terminate_handler, void(*)()>::value, "");
|
||||||
std::terminate_handler p = f;
|
std::terminate_handler p = f;
|
||||||
|
assert(p == &f);
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,8 @@
|
|||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::sig_atomic_t sig;
|
std::sig_atomic_t sig = 0;
|
||||||
|
((void)sig);
|
||||||
typedef void (*func)(int);
|
typedef void (*func)(int);
|
||||||
static_assert((std::is_same<decltype(std::signal(0, (func)0)), func>::value), "");
|
static_assert((std::is_same<decltype(std::signal(0, (func)0)), func>::value), "");
|
||||||
static_assert((std::is_same<decltype(std::raise(0)), int>::value), "");
|
static_assert((std::is_same<decltype(std::raise(0)), int>::value), "");
|
||||||
|
@ -32,4 +32,5 @@
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::va_list va;
|
std::va_list va;
|
||||||
|
((void)va);
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#ifndef EXIT_FAILURE
|
#ifndef EXIT_FAILURE
|
||||||
#error EXIT_FAILURE not defined
|
#error EXIT_FAILURE not defined
|
||||||
@ -32,12 +33,23 @@
|
|||||||
#error RAND_MAX not defined
|
#error RAND_MAX not defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
template <class TestType, class IntType>
|
||||||
|
void test_div_struct() {
|
||||||
|
TestType obj;
|
||||||
|
static_assert(sizeof(obj) >= sizeof(IntType) * 2, ""); // >= to account for alignment.
|
||||||
|
static_assert(std::is_same<decltype(obj.quot), IntType>::value, "");
|
||||||
|
static_assert(std::is_same<decltype(obj.rem), IntType>::value, "");
|
||||||
|
((void) obj);
|
||||||
|
};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::size_t s = 0;
|
std::size_t s = 0;
|
||||||
std::div_t d;
|
((void)s);
|
||||||
std::ldiv_t ld;
|
static_assert(std::is_same<std::size_t, decltype(sizeof(int))>::value, "");
|
||||||
std::lldiv_t lld;
|
test_div_struct<std::div_t, int>();
|
||||||
|
test_div_struct<std::ldiv_t, long>();
|
||||||
|
test_div_struct<std::lldiv_t, long long>();
|
||||||
char** endptr = 0;
|
char** endptr = 0;
|
||||||
static_assert((std::is_same<decltype(std::atof("")), double>::value), "");
|
static_assert((std::is_same<decltype(std::atof("")), double>::value), "");
|
||||||
static_assert((std::is_same<decltype(std::atoi("")), int>::value), "");
|
static_assert((std::is_same<decltype(std::atoi("")), int>::value), "");
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::clock_t c = 0;
|
std::clock_t c = 0;
|
||||||
|
((void)c);
|
||||||
std::size_t s = 0;
|
std::size_t s = 0;
|
||||||
std::time_t t = 0;
|
std::time_t t = 0;
|
||||||
std::tm tm = {0};
|
std::tm tm = {0};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user