Get tests running with warnings. Fix warnings in headers and tests

llvm-svn: 228344
This commit is contained in:
Eric Fiselier 2015-02-05 20:28:37 +00:00
parent d40bb5353d
commit c281a7a19f
26 changed files with 66 additions and 21 deletions

View File

@ -906,7 +906,6 @@ rotate(__bit_iterator<_Cp, false> __first, __bit_iterator<_Cp, false> __middle,
{
typedef __bit_iterator<_Cp, false> _I1;
typedef typename _I1::difference_type difference_type;
typedef typename _I1::__storage_type __storage_type;
difference_type __d1 = __middle - __first;
difference_type __d2 = __last - __middle;
_I1 __r = __first + __d2;

View File

@ -4368,8 +4368,6 @@ __buffered_inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator
typename iterator_traits<_BidirectionalIterator>::value_type* __buff)
{
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
typedef typename iterator_traits<_BidirectionalIterator>::pointer pointer;
__destruct_n __d(0);
unique_ptr<value_type, __destruct_n&> __h2(__buff, __d);
if (__len1 <= __len2)
@ -4403,7 +4401,6 @@ __inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle,
typename iterator_traits<_BidirectionalIterator>::difference_type __len2,
typename iterator_traits<_BidirectionalIterator>::value_type* __buff, ptrdiff_t __buff_size)
{
typedef typename iterator_traits<_BidirectionalIterator>::value_type value_type;
typedef typename iterator_traits<_BidirectionalIterator>::difference_type difference_type;
while (true)
{
@ -4790,7 +4787,6 @@ void
__sift_up(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp,
typename iterator_traits<_RandomAccessIterator>::difference_type __len)
{
typedef typename iterator_traits<_RandomAccessIterator>::difference_type difference_type;
typedef typename iterator_traits<_RandomAccessIterator>::value_type value_type;
if (__len > 1)
{

View File

@ -92,6 +92,7 @@ class Configuration(object):
self.configure_env()
self.configure_compile_flags()
self.configure_link_flags()
self.configure_warnings()
self.configure_sanitizer()
self.configure_substitutions()
self.configure_features()
@ -456,6 +457,14 @@ class Configuration(object):
else:
self.lit_config.fatal("unrecognized system: %r" % sys.platform)
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']
def configure_sanitizer(self):
san = self.get_lit_conf('use_sanitizer', '').strip()
if san:

View File

@ -21,6 +21,7 @@
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};

View File

@ -276,6 +276,7 @@ test3()
const auto f = bind(&TFENode::foo, _1, 0UL);
const TFENode n = TFENode{};
bool b = f(n);
assert(b);
}
int main()

View File

@ -12,13 +12,20 @@
// placeholders
#include <functional>
#include <type_traits>
template <class T>
void
test(const T& t)
{
// Test default constructible.
T t2;
((void)t2);
// Test copy constructible.
T t3 = t;
((void)t3);
static_assert(std::is_nothrow_copy_constructible<T>::value, "");
static_assert(std::is_nothrow_move_constructible<T>::value, "");
}
int main()

View File

@ -17,6 +17,7 @@
int main()
{
{
typedef std::bit_xor<int> F;
const F f = F();
static_assert((std::is_same<int, F::first_argument_type>::value), "" );
@ -27,9 +28,11 @@ int main()
assert(f(0x58D3, 0xEA95) == 0xB246);
assert(f(0x58D3, 0) == 0x58D3);
assert(f(0xFFFF, 0x58D3) == 0xA72C);
}
#if _LIBCPP_STD_VER > 11
{
typedef std::bit_xor<> F2;
const F2 f2 = F2();
const F2 f = F2();
assert(f(0xEA95, 0xEA95) == 0);
assert(f(0xEA95L, 0xEA95) == 0);
assert(f(0xEA95, 0xEA95L) == 0);
@ -55,5 +58,6 @@ int main()
constexpr int bar = std::bit_xor<> () (0x58D3L, 0xEA95);
static_assert ( bar == 0xB246, "" );
}
#endif
}

View File

@ -46,4 +46,5 @@ int main()
std::allocator<char> a2 = a;
a2 = a;
std::allocator<int> a3 = a2;
((void)a3);
}

View File

@ -16,7 +16,6 @@
int main()
{
int i = 0;
const unsigned N = 20;
char buf[N];
void* r;

View File

@ -32,6 +32,7 @@ int main()
std::unique_ptr<A[]> p(new A[3]);
assert(A::count == 3);
A* i = p.get();
assert(i != nullptr);
p.reset();
assert(A::count == 0);
assert(p.get() == 0);
@ -41,6 +42,7 @@ int main()
std::unique_ptr<A[]> p(new A[4]);
assert(A::count == 4);
A* i = p.get();
assert(i != nullptr);
p.reset(new A[5]);
assert(A::count == 5);
}

View File

@ -32,6 +32,7 @@ int main()
std::unique_ptr<A> p(new A);
assert(A::count == 1);
A* i = p.get();
assert(i != nullptr);
p.reset();
assert(A::count == 0);
assert(p.get() == 0);
@ -41,6 +42,7 @@ int main()
std::unique_ptr<A> p(new A);
assert(A::count == 1);
A* i = p.get();
assert(i != nullptr);
p.reset(new A);
assert(A::count == 1);
}

View File

@ -44,6 +44,7 @@ int main()
assert(A::count == 1);
assert(B::count == 0);
A* i = p.get();
assert(i != nullptr);
p.reset(new B);
assert(A::count == 1);
assert(B::count == 1);
@ -55,6 +56,7 @@ int main()
assert(A::count == 1);
assert(B::count == 1);
A* i = p.get();
assert(i != nullptr);
p.reset(new B);
assert(A::count == 1);
assert(B::count == 1);

View File

@ -41,7 +41,9 @@ int main()
std::false_type f1;
std::false_type f2 = f1;
assert(!f2);
std::true_type t1;
std::true_type t2 = t1;
assert(t2);
}

View File

@ -67,13 +67,13 @@ int main()
#endif
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
using type1 = std::result_of<decltype(&wat::foo)(wat)>::type;
static_assert(std::is_same<type1, void>::value, "");
#endif
#if _LIBCPP_STD_VER > 11
using type2 = std::result_of_t<decltype(&wat::foo)(wat)>;
static_assert(std::is_same<type2, void>::value, "");
#endif
static_assert((std::is_same<std::result_of<S(int)>::type, short>::value), "Error!");
static_assert((std::is_same<std::result_of<S&(unsigned char, int&)>::type, double>::value), "Error!");
static_assert((std::is_same<std::result_of<PF1()>::type, bool>::value), "Error!");
@ -92,7 +92,4 @@ int main()
static_assert((std::is_same<std::result_of<int (F::* (F &&)) () const&&>::type, int>::value), "Error!");
static_assert((std::is_same<std::result_of<int (F::* (F const&&)) () const&&>::type, int>::value), "Error!");
#endif
#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
using type = std::result_of<decltype(&wat::foo)(wat)>::type;
#endif
}

View File

@ -45,8 +45,6 @@ void test_class()
class Class
{
int _;
double __;
};
int main()

View File

@ -36,8 +36,6 @@ void test_class()
class Class
{
int _;
double __;
};
int main()

View File

@ -14,9 +14,13 @@
// static time_point now();
#include <chrono>
#include <cassert>
int main()
{
typedef std::chrono::high_resolution_clock C;
C::time_point t1 = C::now();
assert(t1.time_since_epoch().count() != 0);
assert(C::time_point::min() < t1);
assert(C::time_point::max() > t1);
}

View File

@ -20,4 +20,5 @@ int main()
{
typedef std::chrono::system_clock C;
C::time_point t1 = C::from_time_t(C::to_time_t(C::now()));
((void)t1);
}

View File

@ -14,9 +14,13 @@
// static time_point now();
#include <chrono>
#include <cassert>
int main()
{
typedef std::chrono::system_clock C;
C::time_point t1 = C::now();
assert(t1.time_since_epoch().count() != 0);
assert(C::time_point::min() < t1);
assert(C::time_point::max() > t1);
}

View File

@ -20,4 +20,5 @@ int main()
{
typedef std::chrono::system_clock C;
std::time_t t1 = C::to_time_t(C::now());
((void)t1);
}

View File

@ -47,12 +47,12 @@ void test_default_constructible_extension_sfinae()
typedef std::tuple<MoveOnly, MoveOnly, NoDefault> Tuple;
static_assert(!std::is_constructible<
std::tuple<MoveOnly, MoveOnly, NoDefault>,
Tuple,
std::allocator_arg_t, A1<int>, MoveOnly, MoveOnly
>::value, "");
static_assert(std::is_constructible<
std::tuple<MoveOnly, MoveOnly, NoDefault>,
Tuple,
std::allocator_arg_t, A1<int>, MoveOnly, MoveOnly, NoDefault
>::value, "");
}

View File

@ -25,6 +25,7 @@ int main()
typedef std::tuple<> T;
T t0;
T t = t0;
((void)t); // Prevent unused warning
}
{
typedef std::tuple<int> T;
@ -47,7 +48,7 @@ int main()
assert(std::get<1>(t) == 'a');
assert(std::get<2>(t) == "some text");
}
#if _LIBCPP_STD_VER > 11
#if _LIBCPP_STD_VER > 11
{
typedef std::tuple<int> T;
constexpr T t0(2);
@ -58,6 +59,8 @@ int main()
typedef std::tuple<Empty> T;
constexpr T t0;
constexpr T t = t0;
constexpr Empty e = std::get<0>(t);
((void)e); // Prevent unused warning
}
#endif
}

View File

@ -37,6 +37,7 @@ int main()
typedef std::tuple<> T;
T t0;
T t = std::move(t0);
((void)t); // Prevent unused warning
}
{
typedef std::tuple<MoveOnly> T;

View File

@ -25,16 +25,20 @@ int main()
{
{
std::tuple<> t = std::tuple_cat();
((void)t); // Prevent unused warning
}
{
std::tuple<> t1;
std::tuple<> t2 = std::tuple_cat(t1);
((void)t2); // Prevent unused warning
}
{
std::tuple<> t = std::tuple_cat(std::tuple<>());
((void)t); // Prevent unused warning
}
{
std::tuple<> t = std::tuple_cat(std::array<int, 0>());
((void)t); // Prevent unused warning
}
{
std::tuple<int> t1(1);
@ -42,19 +46,23 @@ int main()
assert(std::get<0>(t) == 1);
}
#if _LIBCPP_STD_VER > 11
#if _LIBCPP_STD_VER > 11
{
constexpr std::tuple<> t = std::tuple_cat();
((void)t); // Prevent unused warning
}
{
constexpr std::tuple<> t1;
constexpr std::tuple<> t2 = std::tuple_cat(t1);
((void)t2); // Prevent unused warning
}
{
constexpr std::tuple<> t = std::tuple_cat(std::tuple<>());
((void)t); // Prevent unused warning
}
{
constexpr std::tuple<> t = std::tuple_cat(std::array<int, 0>());
((void)t); // Prevent unused warning
}
{
constexpr std::tuple<int> t1(1);
@ -90,6 +98,7 @@ int main()
std::tuple<> t1;
std::tuple<> t2;
std::tuple<> t3 = std::tuple_cat(t1, t2);
((void)t3); // Prevent unused warning
}
{
std::tuple<> t1;

View File

@ -45,6 +45,7 @@ int main()
typedef std::tuple<Empty> T;
constexpr T t{Empty()};
constexpr Empty e = std::get<0>(t);
((void)e); // Prevent unused warning
}
#endif
{

View File

@ -13,10 +13,13 @@
// type_index(const type_info& rhs);
#include <typeinfo>
#include <typeindex>
#include <cassert>
int main()
{
std::type_index t1 = typeid(int);
std::type_info const & info = typeid(int);
std::type_index t1(info);
assert(t1.name() == info.name());
}