Get tests compiling with -Wunused-local-typedef

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@346914 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Fiselier
2018-11-15 00:11:02 +00:00
parent c6da5c57fe
commit c2c6c1de6b
51 changed files with 22 additions and 94 deletions

View File

@@ -24,15 +24,25 @@ int identity(int v) { return v; }
int sum(int a, int b) { return a + b; }
struct Foo {
int zero() const { return 0; }
int identity(int v) const { return v; }
int sum(int a, int b) const { return a + b; }
int zero() { return 0; }
int zero_const() const { return 1; }
int identity(int v) const { return v; }
int sum(int a, int b) const { return a + b; }
};
int main()
{
typedef std::pointer_to_unary_function<int, int> PUF;
typedef std::pointer_to_binary_function<int, int, int> PBF;
static_assert(
(std::is_same<PUF, decltype(std::ptr_fun<int, int>(identity))>::value),
"");
static_assert(
(std::is_same<PBF, decltype(std::ptr_fun<int, int, int>(sum))>::value),
"");
assert((std::ptr_fun<int, int>(identity)(4) == 4));
assert((std::ptr_fun<int, int, int>(sum)(4, 5) == 9));
@@ -43,6 +53,12 @@ int main()
typedef std::mem_fun_ref_t<int, Foo> MFR;
typedef std::const_mem_fun_ref_t<int, Foo> CMFR;
static_assert(
(std::is_same<MFR, decltype(std::mem_fun_ref(&Foo::zero))>::value), "");
static_assert((std::is_same<CMFR, decltype(std::mem_fun_ref(
&Foo::zero_const))>::value),
"");
assert((std::mem_fun_ref(&Foo::zero)(f) == 0));
assert((std::mem_fun_ref(&Foo::identity)(f, 5) == 5));
}

View File

@@ -106,14 +106,10 @@ struct CountCopiesAllocV2 {
int main()
{
using PMR = ex::memory_resource*;
using PMA = ex::polymorphic_allocator<char>;
{
using T = CountCopies;
using U = CountCopiesAllocV1;
using P = std::pair<T, U>;
using TH = TestHarness<P>;
std::tuple<T> t1;
std::tuple<U> t2;
@@ -129,7 +125,6 @@ int main()
using T = CountCopiesAllocV1;
using U = CountCopiesAllocV2;
using P = std::pair<T, U>;
using TH = TestHarness<P>;
std::tuple<T> t1;
std::tuple<U> t2;
@@ -146,7 +141,6 @@ int main()
using T = CountCopiesAllocV2;
using U = CountCopiesAllocV1;
using P = std::pair<T, U>;
using TH = TestHarness<P>;
std::tuple<T> t1;
std::tuple<U> t2;
@@ -163,7 +157,6 @@ int main()
using T = CountCopiesAllocV2;
using U = CountCopies;
using P = std::pair<T, U>;
using TH = TestHarness<P>;
std::tuple<T> t1;
std::tuple<U> t2;

View File

@@ -30,7 +30,7 @@ namespace ex = std::experimental::pmr;
int main()
{
using Alloc = NullAllocator<char>;
using R = ex::resource_adaptor<Alloc>;
AllocController P;
ex::resource_adaptor<Alloc> r(Alloc{P});
ex::memory_resource & m1 = r;

View File

@@ -57,7 +57,6 @@ int main()
typedef std::chrono::system_clock Clock;
typedef Clock::time_point time_point;
typedef Clock::duration duration;
std::chrono::milliseconds ms(500);
time_point t0 = Clock::now();
std::this_thread::sleep_for(ms);

View File

@@ -84,7 +84,6 @@ int main()
using Container = TCT::map<>;
using Key = Container::key_type;
using MappedType = Container::mapped_type;
using ValueTp = Container::value_type;
ConstructController* cc = getConstructController();
cc->reset();
{

View File

@@ -61,7 +61,6 @@ int main()
using Container = TCT::map<>;
using Key = Container::key_type;
using MappedType = Container::mapped_type;
using ValueTp = Container::value_type;
ConstructController* cc = getConstructController();
cc->reset();
{

View File

@@ -43,9 +43,9 @@ int main()
test_return_type<std::queue<int> > ();
test_return_type<std::queue<int, std::list<int> > > ();
typedef Emplaceable T;
std::queue<Emplaceable> q;
#if TEST_STD_VER > 14
typedef Emplaceable T;
T& r1 = q.emplace(1, 2.5);
assert(&r1 == &q.back());
T& r2 = q.emplace(2, 3.5);

View File

@@ -42,9 +42,9 @@ int main()
test_return_type<std::stack<int> > ();
test_return_type<std::stack<int, std::vector<int> > > ();
typedef Emplaceable T;
std::stack<Emplaceable> q;
#if TEST_STD_VER > 14
typedef Emplaceable T;
T& r1 = q.emplace(1, 2.5);
assert(&r1 == &q.top());
T& r2 = q.emplace(2, 3.5);

View File

@@ -33,10 +33,6 @@ template <class Container>
void testMapInsert()
{
typedef typename Container::value_type ValueTp;
typedef typename Container::key_type Key;
typedef typename Container::mapped_type Mapped;
typedef Container C;
typedef std::pair<typename C::iterator, bool> R;
ConstructController* cc = getConstructController();
cc->reset();
{
@@ -297,8 +293,6 @@ void testMapEmplace()
typedef typename Container::key_type Key;
typedef typename Container::mapped_type Mapped;
typedef typename std::pair<Key, Mapped> NonConstKeyPair;
typedef Container C;
typedef std::pair<typename C::iterator, bool> R;
ConstructController* cc = getConstructController();
cc->reset();
{
@@ -630,7 +624,6 @@ template <class Container>
void testMultimapInsert()
{
typedef typename Container::value_type ValueTp;
typedef Container C;
ConstructController* cc = getConstructController();
cc->reset();
{
@@ -704,7 +697,6 @@ template <class Container>
void testMultimapInsertHint()
{
typedef typename Container::value_type ValueTp;
typedef Container C;
ConstructController* cc = getConstructController();
cc->reset();
{

View File

@@ -88,7 +88,6 @@ int main()
{
// Test that the allocator's construct method is being used to
// construct the new elements and that it's called exactly N times.
typedef int T;
typedef std::forward_list<int, ContainerTestAllocator<int, int>> Container;
ConstructController* cc = getConstructController();
cc->reset();

View File

@@ -183,7 +183,6 @@ void test_ctor_under_alloc() {
int arr2[] = {1, 101, 42};
{
using C = TCT::list<>;
using T = typename C::value_type;
using It = forward_iterator<int*>;
{
ExpectConstructGuard<int&> G(1);
@@ -196,7 +195,6 @@ void test_ctor_under_alloc() {
}
{
using C = TCT::list<>;
using T = typename C::value_type;
using It = input_iterator<int*>;
{
ExpectConstructGuard<int&> G(1);
@@ -216,7 +214,6 @@ void test_ctor_under_alloc_with_alloc() {
int arr2[] = {1, 101, 42};
{
using C = TCT::list<>;
using T = typename C::value_type;
using It = forward_iterator<int*>;
using Alloc = typename C::allocator_type;
Alloc a;
@@ -231,7 +228,6 @@ void test_ctor_under_alloc_with_alloc() {
}
{
using C = TCT::list<>;
using T = typename C::value_type;
using It = input_iterator<int*>;
using Alloc = typename C::allocator_type;
Alloc a;

View File

@@ -121,7 +121,6 @@ void test_ctor_under_alloc() {
int arr2[] = {1, 101, 42};
{
using C = TCT::vector<>;
using T = typename C::value_type;
using It = forward_iterator<int*>;
{
ExpectConstructGuard<int&> G(1);
@@ -134,7 +133,6 @@ void test_ctor_under_alloc() {
}
{
using C = TCT::vector<>;
using T = typename C::value_type;
using It = input_iterator<int*>;
{
ExpectConstructGuard<int&> G(1);

View File

@@ -134,7 +134,6 @@ void test_ctor_under_alloc() {
int arr2[] = {1, 101, 42};
{
using C = TCT::vector<>;
using T = typename C::value_type;
using It = forward_iterator<int*>;
using Alloc = typename C::allocator_type;
Alloc a;
@@ -149,7 +148,6 @@ void test_ctor_under_alloc() {
}
{
using C = TCT::vector<>;
using T = typename C::value_type;
using It = input_iterator<int*>;
using Alloc = typename C::allocator_type;
Alloc a;

View File

@@ -32,8 +32,6 @@ template <class Container>
void testSetInsert()
{
typedef typename Container::value_type ValueTp;
typedef Container C;
typedef std::pair<typename C::iterator, bool> R;
ConstructController* cc = getConstructController();
cc->reset();
{
@@ -146,8 +144,6 @@ template <class Container>
void testSetEmplace()
{
typedef typename Container::value_type ValueTp;
typedef Container C;
typedef std::pair<typename C::iterator, bool> R;
ConstructController* cc = getConstructController();
cc->reset();
{
@@ -209,7 +205,6 @@ template <class Container>
void testSetEmplaceHint()
{
typedef typename Container::value_type ValueTp;
typedef Container C;
typedef typename C::iterator It;
ConstructController* cc = getConstructController();
@@ -289,7 +284,6 @@ template <class Container>
void testMultisetInsert()
{
typedef typename Container::value_type ValueTp;
typedef Container C;
ConstructController* cc = getConstructController();
cc->reset();
{
@@ -356,8 +350,6 @@ template <class Container>
void testMultisetEmplace()
{
typedef typename Container::value_type ValueTp;
typedef Container C;
typedef std::pair<typename C::iterator, bool> R;
ConstructController* cc = getConstructController();
cc->reset();
{

View File

@@ -119,7 +119,6 @@ int main()
using Container = TCT::unordered_map<>;
using Key = Container::key_type;
using MappedType = Container::mapped_type;
using ValueTp = Container::value_type;
ConstructController* cc = getConstructController();
cc->reset();
{

View File

@@ -32,7 +32,6 @@ TEST_SUITE(directory_iterator_increment_tests)
TEST_CASE(test_increment_signatures)
{
using D = directory_iterator;
directory_iterator d; ((void)d);
std::error_code ec; ((void)ec);

View File

@@ -32,7 +32,6 @@ TEST_SUITE(directory_iterator_begin_end_tests)
TEST_CASE(test_function_signatures)
{
using D = directory_iterator;
directory_iterator d; ((void)d);
ASSERT_SAME_TYPE(decltype(begin(d)), directory_iterator);

View File

@@ -31,7 +31,6 @@ TEST_SUITE(recursive_directory_iterator_increment_tests)
TEST_CASE(test_increment_signatures)
{
using D = recursive_directory_iterator;
recursive_directory_iterator d; ((void)d);
std::error_code ec; ((void)ec);

View File

@@ -32,7 +32,6 @@ TEST_SUITE(recursive_directory_iterator_begin_end_tests)
TEST_CASE(test_function_signatures)
{
using D = recursive_directory_iterator;
recursive_directory_iterator d; ((void)d);
ASSERT_SAME_TYPE(decltype(begin(d)), recursive_directory_iterator);

View File

@@ -108,7 +108,6 @@ struct Times {
};
Times GetTimes(path const& p) {
using Clock = file_time_type::clock;
StatT st;
if (::stat(p.c_str(), &st) == -1) {
std::error_code ec(errno, std::generic_category());
@@ -127,7 +126,6 @@ TimeSpec LastAccessTime(path const& p) { return GetTimes(p).access; }
TimeSpec LastWriteTime(path const& p) { return GetTimes(p).write; }
std::pair<TimeSpec, TimeSpec> GetSymlinkTimes(path const& p) {
using Clock = file_time_type::clock;
StatT st;
if (::lstat(p.c_str(), &st) == -1) {
std::error_code ec(errno, std::generic_category());
@@ -510,7 +508,6 @@ TEST_CASE(last_write_time_symlink_test)
TEST_CASE(test_write_min_time)
{
using Clock = file_time_type::clock;
scoped_test_env env;
const path p = env.create_file("file", 42);
const file_time_type old_time = last_write_time(p);
@@ -545,10 +542,6 @@ TEST_CASE(test_write_min_time)
}
TEST_CASE(test_write_max_time) {
using Clock = file_time_type::clock;
using Sec = std::chrono::seconds;
using Hours = std::chrono::hours;
scoped_test_env env;
const path p = env.create_file("file", 42);
const file_time_type old_time = last_write_time(p);

View File

@@ -19,7 +19,6 @@
#include "test_macros.h"
int main() {
typedef std::endian E;
static_assert(std::is_enum<std::endian>::value, "");
// Check that E is a scoped enum by checking for conversions.

View File

@@ -23,7 +23,6 @@
int main()
{
using day = std::chrono::day;
using month = std::chrono::month;
using month_day = std::chrono::month_day;
ASSERT_NOEXCEPT( std::declval<const month_day>().day());

View File

@@ -51,7 +51,6 @@ int main()
using year_month = std::chrono::year_month;
using month_day = std::chrono::month_day;
using year_month_day = std::chrono::year_month_day;
using weekday = std::chrono::weekday;
constexpr month February = std::chrono::February;
constexpr year_month Feb2018{year{2018}, February};

View File

@@ -41,13 +41,9 @@
int main()
{
using month_weekday = std::chrono::month_weekday;
using month = std::chrono::month;
using year_month = std::chrono::year_month;
using year = std::chrono::year;
using weekday_last = std::chrono::weekday_last;
using weekday = std::chrono::weekday;
using month_weekday_last = std::chrono::month_weekday_last;
using month_day_last = std::chrono::month_day_last;
using year_month_day_last = std::chrono::year_month_day_last;

View File

@@ -43,7 +43,6 @@
int main()
{
using year_month = std::chrono::year_month;
using month_weekday = std::chrono::month_weekday;
using year = std::chrono::year;
using month = std::chrono::month;
using weekday = std::chrono::weekday;

View File

@@ -32,7 +32,6 @@ constexpr bool testConstexpr()
int main()
{
using year = std::chrono::year;
using years = std::chrono::years;
ASSERT_NOEXCEPT(+std::declval<year>());
ASSERT_NOEXCEPT(-std::declval<year>());

View File

@@ -32,7 +32,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using month_day_last = std::chrono::month_day_last;
using year_month_day_last = std::chrono::year_month_day_last;

View File

@@ -24,7 +24,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using month_day_last = std::chrono::month_day_last;
using year_month_day_last = std::chrono::year_month_day_last;

View File

@@ -24,7 +24,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using month_day_last = std::chrono::month_day_last;
using year_month_day_last = std::chrono::year_month_day_last;

View File

@@ -24,7 +24,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using month_day_last = std::chrono::month_day_last;
using year_month_day_last = std::chrono::year_month_day_last;

View File

@@ -37,7 +37,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using month_day_last = std::chrono::month_day_last;
using year_month_day_last = std::chrono::year_month_day_last;
using months = std::chrono::months;

View File

@@ -37,7 +37,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using month_day_last = std::chrono::month_day_last;
using year_month_day_last = std::chrono::year_month_day_last;
using years = std::chrono::years;

View File

@@ -24,7 +24,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using month_day_last = std::chrono::month_day_last;
using year_month_day_last = std::chrono::year_month_day_last;

View File

@@ -31,7 +31,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using month_day_last = std::chrono::month_day_last;
using year_month_day_last = std::chrono::year_month_day_last;

View File

@@ -52,7 +52,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using month_day_last = std::chrono::month_day_last;
using year_month_day_last = std::chrono::year_month_day_last;
using months = std::chrono::months;

View File

@@ -68,7 +68,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using month_day_last = std::chrono::month_day_last;
using year_month_day_last = std::chrono::year_month_day_last;
using months = std::chrono::months;

View File

@@ -35,7 +35,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
using year_month_weekday = std::chrono::year_month_weekday;

View File

@@ -24,7 +24,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
using year_month_weekday = std::chrono::year_month_weekday;

View File

@@ -24,8 +24,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
using year_month_weekday = std::chrono::year_month_weekday;

View File

@@ -24,7 +24,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
using year_month_weekday = std::chrono::year_month_weekday;

View File

@@ -37,11 +37,9 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
using year_month_weekday = std::chrono::year_month_weekday;
using years = std::chrono::years;
using months = std::chrono::months;

View File

@@ -37,12 +37,10 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
using year_month_weekday = std::chrono::year_month_weekday;
using years = std::chrono::years;
using months = std::chrono::months;
ASSERT_NOEXCEPT( std::declval<year_month_weekday&>() += std::declval<years>());
ASSERT_SAME_TYPE(year_month_weekday&, decltype(std::declval<year_month_weekday&>() += std::declval<years>()));

View File

@@ -24,7 +24,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
using year_month_weekday = std::chrono::year_month_weekday;

View File

@@ -24,7 +24,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
using year_month_weekday = std::chrono::year_month_weekday;

View File

@@ -24,8 +24,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
using year_month_weekday = std::chrono::year_month_weekday;

View File

@@ -27,7 +27,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using weekday_indexed = std::chrono::weekday_indexed;
using weekday = std::chrono::weekday;
using year_month_weekday = std::chrono::year_month_weekday;

View File

@@ -55,7 +55,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
using year_month_weekday = std::chrono::year_month_weekday;

View File

@@ -56,7 +56,6 @@ int main()
{
using year = std::chrono::year;
using month = std::chrono::month;
using day = std::chrono::day;
using weekday = std::chrono::weekday;
using weekday_indexed = std::chrono::weekday_indexed;
using year_month_weekday = std::chrono::year_month_weekday;

View File

@@ -147,7 +147,6 @@ void test_hash_enabled(InputKey const& key) {
#endif
// Hashable requirements
using CKey = ConvertibleTo<Key>;
static_assert(can_hash<Hash(Key&)>(), "");
static_assert(can_hash<Hash(Key const&)>(), "");
static_assert(can_hash<Hash(Key&&)>(), "");
@@ -187,7 +186,6 @@ void test_hash_disabled() {
>::value, "");
// Hashable requirements
using CKey = ConvertibleTo<Key>;
static_assert(!can_hash<Hash(Key&)>(), "");
static_assert(!can_hash<Hash(Key const&)>(), "");
static_assert(!can_hash<Hash(Key&&)>(), "");

View File

@@ -98,7 +98,6 @@ public:
template <class IncompleteT = IncompleteType,
class Del = std::default_delete<IncompleteT>, class... Args>
void doIncompleteTypeTest(int expect_alive, Args&&... ctor_args) {
using ValueT = typename std::remove_all_extents<IncompleteT>::type;
checkNumIncompleteTypeAlive(expect_alive);
{
StoresIncomplete<IncompleteT, Del> sptr(std::forward<Args>(ctor_args)...);

View File

@@ -931,9 +931,6 @@ class Configuration(object):
self.cxx.addWarningFlagIfSupported('-Wunused-variable')
self.cxx.addWarningFlagIfSupported('-Wunused-parameter')
self.cxx.addWarningFlagIfSupported('-Wunreachable-code')
# FIXME: Enable the two warnings below.
# self.cxx.addWarningFlagIfSupported('-Wno-conversion')
self.cxx.addWarningFlagIfSupported('-Wno-unused-local-typedef')
std = self.get_lit_conf('std', None)
if std in ['c++98', 'c++03']:
# The '#define static_assert' provided by libc++ in C++03 mode