Zhang Xiongpang: Add definitions for const data members. Fixes http://llvm.org/bugs/show_bug.cgi?id=14585.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@170026 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is dual licensed under the MIT and the University of Illinois Open
|
||||
// Source Licenses. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <limits>
|
||||
|
||||
/*
|
||||
<limits>:
|
||||
numeric_limits
|
||||
is_specialized
|
||||
digits
|
||||
digits10
|
||||
max_digits10
|
||||
is_signed
|
||||
is_integer
|
||||
is_exact
|
||||
radix
|
||||
min_exponent
|
||||
min_exponent10
|
||||
max_exponent
|
||||
max_exponent10
|
||||
has_infinity
|
||||
has_quiet_NaN
|
||||
has_signaling_NaN
|
||||
has_denorm
|
||||
has_denorm_loss
|
||||
is_iec559
|
||||
is_bounded
|
||||
is_modulo
|
||||
traps
|
||||
tinyness_before
|
||||
round_style
|
||||
*/
|
||||
|
||||
template <class _Tp>
|
||||
void test(const _Tp &) {}
|
||||
|
||||
#define TEST_NUMERIC_LIMITS(type) \
|
||||
test(std::numeric_limits<type>::is_specialized); \
|
||||
test(std::numeric_limits<type>::digits); \
|
||||
test(std::numeric_limits<type>::digits10); \
|
||||
test(std::numeric_limits<type>::max_digits10); \
|
||||
test(std::numeric_limits<type>::is_signed); \
|
||||
test(std::numeric_limits<type>::is_integer); \
|
||||
test(std::numeric_limits<type>::is_exact); \
|
||||
test(std::numeric_limits<type>::radix); \
|
||||
test(std::numeric_limits<type>::min_exponent); \
|
||||
test(std::numeric_limits<type>::min_exponent10); \
|
||||
test(std::numeric_limits<type>::max_exponent); \
|
||||
test(std::numeric_limits<type>::max_exponent10); \
|
||||
test(std::numeric_limits<type>::has_infinity); \
|
||||
test(std::numeric_limits<type>::has_quiet_NaN); \
|
||||
test(std::numeric_limits<type>::has_signaling_NaN); \
|
||||
test(std::numeric_limits<type>::has_denorm); \
|
||||
test(std::numeric_limits<type>::has_denorm_loss); \
|
||||
test(std::numeric_limits<type>::is_iec559); \
|
||||
test(std::numeric_limits<type>::is_bounded); \
|
||||
test(std::numeric_limits<type>::is_modulo); \
|
||||
test(std::numeric_limits<type>::traps); \
|
||||
test(std::numeric_limits<type>::tinyness_before); \
|
||||
test(std::numeric_limits<type>::round_style);
|
||||
|
||||
struct other {};
|
||||
|
||||
int main()
|
||||
{
|
||||
// bool
|
||||
TEST_NUMERIC_LIMITS(bool)
|
||||
TEST_NUMERIC_LIMITS(const bool)
|
||||
TEST_NUMERIC_LIMITS(volatile bool)
|
||||
TEST_NUMERIC_LIMITS(const volatile bool)
|
||||
|
||||
// char
|
||||
TEST_NUMERIC_LIMITS(char)
|
||||
TEST_NUMERIC_LIMITS(const char)
|
||||
TEST_NUMERIC_LIMITS(volatile char)
|
||||
TEST_NUMERIC_LIMITS(const volatile char)
|
||||
|
||||
// signed char
|
||||
TEST_NUMERIC_LIMITS(signed char)
|
||||
TEST_NUMERIC_LIMITS(const signed char)
|
||||
TEST_NUMERIC_LIMITS(volatile signed char)
|
||||
TEST_NUMERIC_LIMITS(const volatile signed char)
|
||||
|
||||
// unsigned char
|
||||
TEST_NUMERIC_LIMITS(unsigned char)
|
||||
TEST_NUMERIC_LIMITS(const unsigned char)
|
||||
TEST_NUMERIC_LIMITS(volatile unsigned char)
|
||||
TEST_NUMERIC_LIMITS(const volatile unsigned char)
|
||||
|
||||
// wchar_t
|
||||
TEST_NUMERIC_LIMITS(wchar_t)
|
||||
TEST_NUMERIC_LIMITS(const wchar_t)
|
||||
TEST_NUMERIC_LIMITS(volatile wchar_t)
|
||||
TEST_NUMERIC_LIMITS(const volatile wchar_t)
|
||||
|
||||
// char16_t
|
||||
TEST_NUMERIC_LIMITS(char16_t)
|
||||
TEST_NUMERIC_LIMITS(const char16_t)
|
||||
TEST_NUMERIC_LIMITS(volatile char16_t)
|
||||
TEST_NUMERIC_LIMITS(const volatile char16_t)
|
||||
|
||||
// char32_t
|
||||
TEST_NUMERIC_LIMITS(char32_t)
|
||||
TEST_NUMERIC_LIMITS(const char32_t)
|
||||
TEST_NUMERIC_LIMITS(volatile char32_t)
|
||||
TEST_NUMERIC_LIMITS(const volatile char32_t)
|
||||
|
||||
// short
|
||||
TEST_NUMERIC_LIMITS(short)
|
||||
TEST_NUMERIC_LIMITS(const short)
|
||||
TEST_NUMERIC_LIMITS(volatile short)
|
||||
TEST_NUMERIC_LIMITS(const volatile short)
|
||||
|
||||
// int
|
||||
TEST_NUMERIC_LIMITS(int)
|
||||
TEST_NUMERIC_LIMITS(const int)
|
||||
TEST_NUMERIC_LIMITS(volatile int)
|
||||
TEST_NUMERIC_LIMITS(const volatile int)
|
||||
|
||||
// long
|
||||
TEST_NUMERIC_LIMITS(long)
|
||||
TEST_NUMERIC_LIMITS(const long)
|
||||
TEST_NUMERIC_LIMITS(volatile long)
|
||||
TEST_NUMERIC_LIMITS(const volatile long)
|
||||
|
||||
// long long
|
||||
TEST_NUMERIC_LIMITS(long long)
|
||||
TEST_NUMERIC_LIMITS(const long long)
|
||||
TEST_NUMERIC_LIMITS(volatile long long)
|
||||
TEST_NUMERIC_LIMITS(const volatile long long)
|
||||
|
||||
// unsigned short
|
||||
TEST_NUMERIC_LIMITS(unsigned short)
|
||||
TEST_NUMERIC_LIMITS(const unsigned short)
|
||||
TEST_NUMERIC_LIMITS(volatile unsigned short)
|
||||
TEST_NUMERIC_LIMITS(const volatile unsigned short)
|
||||
|
||||
// unsigned int
|
||||
TEST_NUMERIC_LIMITS(unsigned int)
|
||||
TEST_NUMERIC_LIMITS(const unsigned int)
|
||||
TEST_NUMERIC_LIMITS(volatile unsigned int)
|
||||
TEST_NUMERIC_LIMITS(const volatile unsigned int)
|
||||
|
||||
// unsigned long
|
||||
TEST_NUMERIC_LIMITS(unsigned long)
|
||||
TEST_NUMERIC_LIMITS(const unsigned long)
|
||||
TEST_NUMERIC_LIMITS(volatile unsigned long)
|
||||
TEST_NUMERIC_LIMITS(const volatile unsigned long)
|
||||
|
||||
// unsigned long long
|
||||
TEST_NUMERIC_LIMITS(unsigned long long)
|
||||
TEST_NUMERIC_LIMITS(const unsigned long long)
|
||||
TEST_NUMERIC_LIMITS(volatile unsigned long long)
|
||||
TEST_NUMERIC_LIMITS(const volatile unsigned long long)
|
||||
|
||||
// float
|
||||
TEST_NUMERIC_LIMITS(float)
|
||||
TEST_NUMERIC_LIMITS(const float)
|
||||
TEST_NUMERIC_LIMITS(volatile float)
|
||||
TEST_NUMERIC_LIMITS(const volatile float)
|
||||
|
||||
// double
|
||||
TEST_NUMERIC_LIMITS(double)
|
||||
TEST_NUMERIC_LIMITS(const double)
|
||||
TEST_NUMERIC_LIMITS(volatile double)
|
||||
TEST_NUMERIC_LIMITS(const volatile double)
|
||||
|
||||
// long double
|
||||
TEST_NUMERIC_LIMITS(long double)
|
||||
TEST_NUMERIC_LIMITS(const long double)
|
||||
TEST_NUMERIC_LIMITS(volatile long double)
|
||||
TEST_NUMERIC_LIMITS(const volatile long double)
|
||||
|
||||
// other
|
||||
TEST_NUMERIC_LIMITS(other)
|
||||
TEST_NUMERIC_LIMITS(const other)
|
||||
TEST_NUMERIC_LIMITS(volatile other)
|
||||
TEST_NUMERIC_LIMITS(const volatile other)
|
||||
}
|
@@ -31,6 +31,9 @@
|
||||
#include <locale>
|
||||
#include <cassert>
|
||||
|
||||
template <class _Tp>
|
||||
void test(const _Tp &) {}
|
||||
|
||||
int main()
|
||||
{
|
||||
assert(std::ctype_base::space);
|
||||
@@ -54,4 +57,17 @@ int main()
|
||||
& std::ctype_base::xdigit) == 0);
|
||||
assert(std::ctype_base::alnum == (std::ctype_base::alpha | std::ctype_base::digit));
|
||||
assert(std::ctype_base::graph == (std::ctype_base::alnum | std::ctype_base::punct));
|
||||
|
||||
test(std::ctype_base::space);
|
||||
test(std::ctype_base::print);
|
||||
test(std::ctype_base::cntrl);
|
||||
test(std::ctype_base::upper);
|
||||
test(std::ctype_base::lower);
|
||||
test(std::ctype_base::alpha);
|
||||
test(std::ctype_base::digit);
|
||||
test(std::ctype_base::punct);
|
||||
test(std::ctype_base::xdigit);
|
||||
test(std::ctype_base::blank);
|
||||
test(std::ctype_base::alnum);
|
||||
test(std::ctype_base::graph);
|
||||
}
|
||||
|
@@ -17,10 +17,14 @@
|
||||
// public:
|
||||
// typedef _CharT char_type;
|
||||
// typedef basic_string<char_type> string_type;
|
||||
// static const bool intl = International;
|
||||
|
||||
#include <locale>
|
||||
#include <type_traits>
|
||||
|
||||
template <class _Tp>
|
||||
void test(const _Tp &) {}
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_base_of<std::locale::facet, std::moneypunct<char> >::value), "");
|
||||
@@ -31,4 +35,9 @@ int main()
|
||||
static_assert((std::is_same<std::moneypunct<wchar_t>::char_type, wchar_t>::value), "");
|
||||
static_assert((std::is_same<std::moneypunct<char>::string_type, std::string>::value), "");
|
||||
static_assert((std::is_same<std::moneypunct<wchar_t>::string_type, std::wstring>::value), "");
|
||||
|
||||
test(std::moneypunct<char, false>::intl);
|
||||
test(std::moneypunct<char, true>::intl);
|
||||
test(std::moneypunct<wchar_t, false>::intl);
|
||||
test(std::moneypunct<wchar_t, true>::intl);
|
||||
}
|
||||
|
@@ -15,6 +15,10 @@
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
template <class _Tp>
|
||||
void test(const _Tp &) {}
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
static_assert((std::is_same<std::locale::category, int>::value), "");
|
||||
@@ -38,4 +42,13 @@ int main()
|
||||
| std::locale::time
|
||||
| std::locale::messages)
|
||||
== std::locale::all);
|
||||
|
||||
test(std::locale::none);
|
||||
test(std::locale::collate);
|
||||
test(std::locale::ctype);
|
||||
test(std::locale::monetary);
|
||||
test(std::locale::numeric);
|
||||
test(std::locale::time);
|
||||
test(std::locale::messages);
|
||||
test(std::locale::all);
|
||||
}
|
||||
|
@@ -26,6 +26,9 @@
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
template <class _Tp>
|
||||
void where(const _Tp &) {}
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
@@ -34,6 +37,8 @@ test1()
|
||||
static_assert((E::used_block == 23), "");
|
||||
/*static_*/assert((E::min() == 0)/*, ""*/);
|
||||
/*static_*/assert((E::max() == 0xFFFFFF)/*, ""*/);
|
||||
where(E::block_size);
|
||||
where(E::used_block);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -44,6 +49,8 @@ test2()
|
||||
static_assert((E::used_block == 11), "");
|
||||
/*static_*/assert((E::min() == 0)/*, ""*/);
|
||||
/*static_*/assert((E::max() == 0xFFFFFFFFFFFFull)/*, ""*/);
|
||||
where(E::block_size);
|
||||
where(E::used_block);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@@ -25,6 +25,9 @@
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
template <class _Tp>
|
||||
void where(const _Tp &) {}
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
@@ -32,6 +35,7 @@ test1()
|
||||
static_assert(E::table_size == 256, "");
|
||||
/*static_*/assert((E::min() == 1)/*, ""*/);
|
||||
/*static_*/assert((E::max() == 2147483646)/*, ""*/);
|
||||
where(E::table_size);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@@ -25,6 +25,9 @@
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
template <class _Tp>
|
||||
void where(const _Tp &) {}
|
||||
|
||||
template <class T, T a, T c, T m>
|
||||
void
|
||||
test1()
|
||||
@@ -37,6 +40,10 @@ test1()
|
||||
/*static_*/assert((LCE::min() == (c == 0u ? 1u: 0u))/*, ""*/);
|
||||
/*static_*/assert((LCE::max() == result_type(m - 1u))/*, ""*/);
|
||||
static_assert((LCE::default_seed == 1), "");
|
||||
where(LCE::multiplier);
|
||||
where(LCE::increment);
|
||||
where(LCE::modulus);
|
||||
where(LCE::default_seed);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
|
@@ -40,6 +40,9 @@
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
template <class _Tp>
|
||||
void where(const _Tp &) {}
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
@@ -60,6 +63,20 @@ test1()
|
||||
/*static_*/assert((E::min() == 0)/*, ""*/);
|
||||
/*static_*/assert((E::max() == 0xFFFFFFFF)/*, ""*/);
|
||||
static_assert((E::default_seed == 5489u), "");
|
||||
where(E::word_size);
|
||||
where(E::state_size);
|
||||
where(E::shift_size);
|
||||
where(E::mask_bits);
|
||||
where(E::xor_mask);
|
||||
where(E::tempering_u);
|
||||
where(E::tempering_d);
|
||||
where(E::tempering_s);
|
||||
where(E::tempering_b);
|
||||
where(E::tempering_t);
|
||||
where(E::tempering_c);
|
||||
where(E::tempering_l);
|
||||
where(E::initialization_multiplier);
|
||||
where(E::default_seed);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -82,6 +99,20 @@ test2()
|
||||
/*static_*/assert((E::min() == 0)/*, ""*/);
|
||||
/*static_*/assert((E::max() == 0xFFFFFFFFFFFFFFFFull)/*, ""*/);
|
||||
static_assert((E::default_seed == 5489u), "");
|
||||
where(E::word_size);
|
||||
where(E::state_size);
|
||||
where(E::shift_size);
|
||||
where(E::mask_bits);
|
||||
where(E::xor_mask);
|
||||
where(E::tempering_u);
|
||||
where(E::tempering_d);
|
||||
where(E::tempering_s);
|
||||
where(E::tempering_b);
|
||||
where(E::tempering_t);
|
||||
where(E::tempering_c);
|
||||
where(E::tempering_l);
|
||||
where(E::initialization_multiplier);
|
||||
where(E::default_seed);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@@ -28,6 +28,9 @@
|
||||
#include <type_traits>
|
||||
#include <cassert>
|
||||
|
||||
template <class _Tp>
|
||||
void where(const _Tp &) {}
|
||||
|
||||
void
|
||||
test1()
|
||||
{
|
||||
@@ -38,6 +41,10 @@ test1()
|
||||
/*static_*/assert((E::min() == 0)/*, ""*/);
|
||||
/*static_*/assert((E::max() == 0xFFFFFF)/*, ""*/);
|
||||
static_assert((E::default_seed == 19780503u), "");
|
||||
where(E::word_size);
|
||||
where(E::short_lag);
|
||||
where(E::long_lag);
|
||||
where(E::default_seed);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -50,6 +57,10 @@ test2()
|
||||
/*static_*/assert((E::min() == 0)/*, ""*/);
|
||||
/*static_*/assert((E::max() == 0xFFFFFFFFFFFFull)/*, ""*/);
|
||||
static_assert((E::default_seed == 19780503u), "");
|
||||
where(E::word_size);
|
||||
where(E::short_lag);
|
||||
where(E::long_lag);
|
||||
where(E::default_seed);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@@ -28,6 +28,9 @@
|
||||
#include <regex>
|
||||
#include <type_traits>
|
||||
|
||||
template <class _Tp>
|
||||
void where(const _Tp &) {}
|
||||
|
||||
template <class CharT>
|
||||
void
|
||||
test()
|
||||
@@ -43,6 +46,16 @@ test()
|
||||
static_assert((BR::awk == std::regex_constants::awk), "");
|
||||
static_assert((BR::grep == std::regex_constants::grep), "");
|
||||
static_assert((BR::egrep == std::regex_constants::egrep), "");
|
||||
where(BR::icase);
|
||||
where(BR::nosubs);
|
||||
where(BR::optimize);
|
||||
where(BR::collate);
|
||||
where(BR::ECMAScript);
|
||||
where(BR::basic);
|
||||
where(BR::extended);
|
||||
where(BR::awk);
|
||||
where(BR::grep);
|
||||
where(BR::egrep);
|
||||
}
|
||||
|
||||
int main()
|
||||
|
@@ -15,6 +15,9 @@
|
||||
|
||||
#include <chrono>
|
||||
|
||||
template <class _Tp>
|
||||
void test(const _Tp &) {}
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::high_resolution_clock C;
|
||||
@@ -22,4 +25,5 @@ int main()
|
||||
static_assert((std::is_same<C::period, C::duration::period>::value), "");
|
||||
static_assert((std::is_same<C::duration, C::time_point::duration>::value), "");
|
||||
static_assert(C::is_steady || !C::is_steady, "");
|
||||
test(std::chrono::high_resolution_clock::is_steady);
|
||||
}
|
||||
|
@@ -15,6 +15,9 @@
|
||||
|
||||
#include <chrono>
|
||||
|
||||
template <class _Tp>
|
||||
void test(const _Tp &) {}
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::steady_clock C;
|
||||
@@ -22,4 +25,5 @@ int main()
|
||||
static_assert((std::is_same<C::period, C::duration::period>::value), "");
|
||||
static_assert((std::is_same<C::duration, C::time_point::duration>::value), "");
|
||||
static_assert(C::is_steady, "");
|
||||
test(std::chrono::steady_clock::is_steady);
|
||||
}
|
||||
|
@@ -15,6 +15,9 @@
|
||||
|
||||
#include <chrono>
|
||||
|
||||
template <class _Tp>
|
||||
void test(const _Tp &) {}
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef std::chrono::system_clock C;
|
||||
@@ -23,4 +26,5 @@ int main()
|
||||
static_assert((std::is_same<C::duration, C::time_point::duration>::value), "");
|
||||
static_assert((std::is_same<C::time_point::clock, C>::value), "");
|
||||
static_assert((C::is_steady || !C::is_steady), "");
|
||||
test(std::chrono::system_clock::is_steady);
|
||||
}
|
||||
|
Reference in New Issue
Block a user