fixed some _Float16 detection issues

also:
- fixed a few minor issues with tests
- removed `__fp16` support (it was always broken)
This commit is contained in:
Mark Gillard 2022-10-17 20:08:26 +03:00
parent 12f9c67bd7
commit c8780a5b8e
14 changed files with 198 additions and 145 deletions

View File

@ -132,7 +132,7 @@ jobs:
steps:
- name: Install dependencies
run: |
python3 -m pip install -U pip==21.3.1
python3 -m pip install -U pip
pip3 install meson ninja
- uses: actions/checkout@v3

View File

@ -29,7 +29,7 @@ jobs:
run: |
apt -y update
apt -y install --no-install-recommends git python3 python3-pip doxygen
pip3 install --upgrade --requirement tools/requirements.txt
pip3 install --upgrade poxy
- name: Generate docs
run: |

View File

@ -26,6 +26,8 @@ template:
#### Fixes:
- fixed null pointer dereference in parser when exceptions are disabled (#169) (@ncaklovic)
- fixed spurious warnings in MSVC 19.34
- fixed some `_Float16` detection issues
<br><br>

View File

@ -1,5 +1,7 @@
# this is a config file for Poxy - a Doxygen + m.css front-end written in Python.
# https://github.com/marzer/poxy
#
# config reference: https://github.com/marzer/poxy/wiki/Configuration-options
name = 'toml++'
author = 'Mark Gillard'

View File

@ -625,11 +625,6 @@ TOML_IMPL_NAMESPACE_START
template <typename T>
struct float_traits : float_traits_base<T, std::numeric_limits<T>::digits, std::numeric_limits<T>::digits10>
{};
#ifdef TOML_FP16
template <>
struct float_traits<TOML_FP16> : float_traits_base<TOML_FP16, __FLT16_MANT_DIG__, __FLT16_DIG__>
{};
#endif
#ifdef TOML_FLOAT16
template <>
struct float_traits<TOML_FLOAT16> : float_traits_base<TOML_FLOAT16, __FLT16_MANT_DIG__, __FLT16_DIG__>
@ -651,11 +646,6 @@ TOML_IMPL_NAMESPACE_START
template <>
struct value_traits<long double> : float_traits<long double>
{};
#ifdef TOML_FP16
template <>
struct value_traits<TOML_FP16> : float_traits<TOML_FP16>
{};
#endif
#ifdef TOML_FLOAT16
template <>
struct value_traits<TOML_FLOAT16> : float_traits<TOML_FLOAT16>

View File

@ -31,7 +31,7 @@
#endif
//#=====================================================================================================================
//# COMPILER/OS/ARCH DETECTION
//# COMPILER / OS
//#=====================================================================================================================
#ifdef __clang__
@ -75,11 +75,46 @@
#else
#define TOML_INTELLISENSE 0
#endif
#if defined(__aarch64__) || defined(__ARM_ARCH_ISA_A64) || defined(_M_ARM64) || defined(__ARM_64BIT_STATE) \
|| defined(__arm__) || defined(_M_ARM) || defined(__ARM_32BIT_STATE)
#define TOML_ARM 1
//#=====================================================================================================================
//# ARCHITECTURE
//#=====================================================================================================================
// IA64
#if defined(__ia64__) || defined(__ia64) || defined(_IA64) || defined(__IA64__) || defined(_M_IA64)
#define TOML_ARCH_ITANIUM 1
#else
#define TOML_ARM 0
#define TOML_ARCH_ITANIUM 0
#endif
// AMD64
#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64)
#define TOML_ARCH_AMD64 1
#else
#define TOML_ARCH_AMD64 0
#endif
// 32-bit x86
#if defined(__i386__) || defined(_M_IX86)
#define TOML_ARCH_X86 1
#else
#define TOML_ARCH_X86 0
#endif
// ARM
#if defined(__aarch64__) || defined(__ARM_ARCH_ISA_A64) || defined(_M_ARM64) || defined(__ARM_64BIT_STATE) \
|| defined(_M_ARM64EC)
#define TOML_ARCH_ARM32 0
#define TOML_ARCH_ARM64 1
#define TOML_ARCH_ARM 1
#elif defined(__arm__) || defined(_M_ARM) || defined(__ARM_32BIT_STATE)
#define TOML_ARCH_ARM32 1
#define TOML_ARCH_ARM64 0
#define TOML_ARCH_ARM 1
#else
#define TOML_ARCH_ARM32 0
#define TOML_ARCH_ARM64 0
#define TOML_ARCH_ARM 0
#endif
//#=====================================================================================================================
@ -1016,40 +1051,62 @@ TOML_ENABLE_WARNINGS;
//# }}
//#=====================================================================================================================
//# EXTENDED INT AND FLOAT TYPES
//# FLOAT16
//#=====================================================================================================================
// clang-format off
#ifdef __FLT16_MANT_DIG__
#if __FLT_RADIX__ == 2 \
&& __FLT16_MANT_DIG__ == 11 \
&& __FLT16_DIG__ == 3 \
&& __FLT16_MIN_EXP__ == -13 \
&& __FLT16_MIN_10_EXP__ == -4 \
&& __FLT16_MAX_EXP__ == 16 \
&& __FLT16_MAX_10_EXP__ == 4
#if TOML_ARM && (TOML_GCC || TOML_CLANG)
#define TOML_FP16 __fp16
#endif
#if TOML_ARM && TOML_CLANG // not present in g++
#define TOML_FLOAT16 _Float16
#endif
#endif
#if TOML_CLANG
//# {{
// Excerpt from https://clang.llvm.org/docs/LanguageExtensions.html:
//
// _Float16 is currently only supported on the following targets,
// with further targets pending ABI standardization:
//
// 32-bit ARM
// 64-bit ARM (AArch64)
// AMDGPU
// SPIR
// X86 as long as SSE2 is available
//
//# }}
#if (TOML_ARCH_ARM || TOML_ARCH_X86 || TOML_ARCH_AMD64) && defined(__FLT16_MANT_DIG__)
#define TOML_FLOAT16 _Float16
#endif
#elif TOML_GCC
//# {{
// Excerpt from https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html:
//
// The _Float16 type is supported on AArch64 systems by default, on ARM systems when the IEEE format for
// 16-bit floating-point types is selected with -mfp16-format=ieee and,
// for both C and C++, on x86 systems with SSE2 enabled.
//
// *** except: the bit about x86 seems incorrect?? ***
//# }}
/*
*/
#if (TOML_ARCH_ARM /*|| TOML_ARCH_X86 || TOML_ARCH_AMD64*/) && defined(__FLT16_MANT_DIG__)
#define TOML_FLOAT16 _Float16
#endif
#endif
#if defined(__SIZEOF_FLOAT128__) \
&& defined(__FLT128_MANT_DIG__) \
&& defined(__LDBL_MANT_DIG__) \
//#=====================================================================================================================
//# FLOAT128
//#=====================================================================================================================
#if defined(__SIZEOF_FLOAT128__) && defined(__FLT128_MANT_DIG__) && defined(__LDBL_MANT_DIG__) \
&& __FLT128_MANT_DIG__ > __LDBL_MANT_DIG__
#define TOML_FLOAT128 __float128
#define TOML_FLOAT128 __float128
#endif
//#=====================================================================================================================
//# INT128
//#=====================================================================================================================
#ifdef __SIZEOF_INT128__
#define TOML_INT128 __int128_t
#define TOML_UINT128 __uint128_t
#define TOML_INT128 __int128_t
#define TOML_UINT128 __uint128_t
#endif
// clang-format on
//#====================================================================================================================
//# VERSIONS AND NAMESPACES
//#====================================================================================================================

View File

@ -90,7 +90,12 @@ TOML_POP_WARNINGS;
#undef TOML_ANON_NAMESPACE
#undef TOML_ANON_NAMESPACE_END
#undef TOML_ANON_NAMESPACE_START
#undef TOML_ARM
#undef TOML_ARCH_ARM
#undef TOML_ARCH_AMD64
#undef TOML_ARCH_ARM32
#undef TOML_ARCH_ARM64
#undef TOML_ARCH_ITANIUM
#undef TOML_ARCH_X86
#undef TOML_ASSERT
#undef TOML_ASSERT_ASSUME
#undef TOML_ASSUME
@ -127,7 +132,6 @@ TOML_POP_WARNINGS;
#undef TOML_FLOAT_CHARCONV
#undef TOML_FLOAT128
#undef TOML_FLOAT16
#undef TOML_FP16
#undef TOML_GCC
#undef TOML_HAS_ATTR
#undef TOML_HAS_BUILTIN

View File

@ -250,9 +250,6 @@ compiler_supports_char8_args = []
if is_gcc or is_clang
compiler_supports_char8_args += '-fchar8_t'
endif
compiler_supports_char8_args_private = []
compiler_supports_char8_args_private += compiler_supports_cpp20_args
compiler_supports_char8_args_private += compiler_supports_char8_args
compiler_supports_char8 = compiler_supports_cpp20 and compiler.links('''
#include <version>
#include <string_view>
@ -278,7 +275,7 @@ compiler_supports_char8 = compiler_supports_cpp20 and compiler.links('''
}
''',
name: 'supports char8_t',
args: compiler_supports_char8_args_private
args: [ compiler_supports_cpp20_args, compiler_supports_char8_args ]
)
#######################################################################################################################
@ -325,27 +322,6 @@ compiler_supports_consteval_properly = compiler_supports_consteval and not compi
# __fp16 and _Float16 checks
#######################################################################################################################
float_16_preprocessor_single_check_template = '''
#ifndef @0@
#error @0@ wasn't defined!
#else
#pragma message("@0@: " MAKE_STRING(@0@))
#endif
#if @0@ != @1@
#error @0@ was not @1@!
#endif
'''
float_16_preprocessor_checks = '''
#define MAKE_STRING(s) MAKE_STRING_1(s)
#define MAKE_STRING_1(s) #s
''' + float_16_preprocessor_single_check_template.format('__FLT_RADIX__', '2') \
+ float_16_preprocessor_single_check_template.format('__FLT16_MANT_DIG__', '11') \
+ float_16_preprocessor_single_check_template.format('__FLT16_DIG__', '3') \
+ float_16_preprocessor_single_check_template.format('__FLT16_MIN_EXP__', '-13') \
+ float_16_preprocessor_single_check_template.format('__FLT16_MIN_10_EXP__', '-4') \
+ float_16_preprocessor_single_check_template.format('__FLT16_MAX_EXP__', '16') \
+ float_16_preprocessor_single_check_template.format('__FLT16_MAX_10_EXP__', '4')
compiler_supports_float16_args = []
if is_gcc
compiler_supports_float16_args += '-mfp16-format=ieee'
@ -364,8 +340,6 @@ compiler_supports_fp16 = compiler.links('''
args: compiler_supports_float16_args
)
compiler_supports_float16 = compiler.links('''
@0@
int main()
{
static_assert(sizeof(_Float16) == 2);
@ -374,7 +348,7 @@ compiler_supports_float16 = compiler.links('''
const auto f3 = static_cast<_Float16>(0.2L);
return 0;
}
'''.format(float_16_preprocessor_checks),
''',
name: 'supports _Float16',
args: compiler_supports_float16_args
)

View File

@ -430,16 +430,16 @@ zyx = 42)"sv;
zyx = 42)"sv;
static constexpr auto table_quoted_no_close = R"(["where will it end]
name = value)"sv;
static constexpr auto table_redefine = R"(# Define b as int, and try to use it as a table: error
static constexpr auto table_redefine = R"(# Define b as int, and try to use it as a table: error
[a]
b = 1
[a.b]
c = 2)"sv;
static constexpr auto table_rrbrace = R"([[table] ])"sv;
static constexpr auto table_text_after_table = R"([error] this shouldn't be here)"sv;
static constexpr auto table_whitespace = R"([invalid key])"sv;
static constexpr auto table_with_pound = R"([key#group]
static constexpr auto table_rrbrace = R"([[table] ])"sv;
static constexpr auto table_text_after_table = R"([error] this shouldn't be here)"sv;
static constexpr auto table_whitespace = R"([invalid key])"sv;
static constexpr auto table_with_pound = R"([key#group]
answer = 42)"sv;
}

View File

@ -64,9 +64,6 @@ namespace toml
CHECK_CAN_REPRESENT_NATIVE(TOML_INT128, true);
CHECK_CAN_REPRESENT_NATIVE(TOML_UINT128, false);
#endif
#ifdef TOML_FP16
CHECK_CAN_REPRESENT_NATIVE(TOML_FP16, false);
#endif
#ifdef TOML_FLOAT16
CHECK_CAN_REPRESENT_NATIVE(TOML_FLOAT16, false);
#endif
@ -292,9 +289,6 @@ namespace toml
CHECK_INSERTED_AS(uint32_t, value<int64_t>);
CHECK_INSERTED_AS(float, value<double>);
CHECK_INSERTED_AS(double, value<double>);
#ifdef TOML_FP16
CHECK_INSERTED_AS(TOML_FP16, value<double>);
#endif
#ifdef TOML_FLOAT16
CHECK_INSERTED_AS(TOML_FLOAT16, value<double>);
#endif

View File

@ -40,10 +40,10 @@ endif
#######################################################################################################################
compiler_supports_fast_math_args = []
if compiler.get_id() == 'gcc' or compiler.get_id() == 'clang'
if is_gcc or is_clang
compiler_supports_fast_math_args += '-ffast-math'
compiler_supports_fast_math_args += '-ffp-contract=fast'
elif compiler.get_id() == 'msvc' or compiler.get_id() == 'intel-cl'
elif is_msvc or is_icc_cl
compiler_supports_fast_math_args += '/fp:fast'
endif
compiler_supports_fast_math = compiler.links('''
@ -186,13 +186,8 @@ foreach cpp20 : cpp20_modes
test_args += compiler_supports_fast_math_args
endif
if compiler_supports_float16 or compiler_supports_fp16
if compiler_supports_fp16
test_args += '-DSHOULD_HAVE_FP16=1'
endif
if compiler_supports_float16
test_args += '-DSHOULD_HAVE_FLOAT16=1'
endif
if compiler_supports_float16
test_args += '-DSHOULD_HAVE_FLOAT16=1'
endif
if compiler_supports_int128
test_args += '-DSHOULD_HAVE_INT128=1'

View File

@ -11,9 +11,6 @@
#else
#include "../include/toml++/toml.h"
#endif
#if defined(TOML_FP16) ^ SHOULD_HAVE_FP16
#error TOML_FP16 was not deduced correctly
#endif
#if defined(TOML_FLOAT16) ^ SHOULD_HAVE_FLOAT16
#error TOML_FLOAT16 was not deduced correctly
#endif
@ -410,3 +407,20 @@ namespace Catch
extern template std::string stringify(const node_view<const node>&);
}
}
#if TOML_CPP >= 20 && TOML_CLANG && TOML_CLANG <= 14 // https://github.com/llvm/llvm-project/issues/55560
TOML_PUSH_WARNINGS;
TOML_DISABLE_WARNINGS;
namespace
{
[[maybe_unused]] static std::u8string clang_string_workaround(const char8_t* a, const char8_t* b)
{
return { a, b };
}
}
TOML_POP_WARNINGS;
#endif

View File

@ -111,11 +111,42 @@
#else
#define TOML_INTELLISENSE 0
#endif
#if defined(__aarch64__) || defined(__ARM_ARCH_ISA_A64) || defined(_M_ARM64) || defined(__ARM_64BIT_STATE) \
|| defined(__arm__) || defined(_M_ARM) || defined(__ARM_32BIT_STATE)
#define TOML_ARM 1
// IA64
#if defined(__ia64__) || defined(__ia64) || defined(_IA64) || defined(__IA64__) || defined(_M_IA64)
#define TOML_ARCH_ITANIUM 1
#else
#define TOML_ARM 0
#define TOML_ARCH_ITANIUM 0
#endif
// AMD64
#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64)
#define TOML_ARCH_AMD64 1
#else
#define TOML_ARCH_AMD64 0
#endif
// 32-bit x86
#if defined(__i386__) || defined(_M_IX86)
#define TOML_ARCH_X86 1
#else
#define TOML_ARCH_X86 0
#endif
// ARM
#if defined(__aarch64__) || defined(__ARM_ARCH_ISA_A64) || defined(_M_ARM64) || defined(__ARM_64BIT_STATE) \
|| defined(_M_ARM64EC)
#define TOML_ARCH_ARM32 0
#define TOML_ARCH_ARM64 1
#define TOML_ARCH_ARM 1
#elif defined(__arm__) || defined(_M_ARM) || defined(__ARM_32BIT_STATE)
#define TOML_ARCH_ARM32 1
#define TOML_ARCH_ARM64 0
#define TOML_ARCH_ARM 1
#else
#define TOML_ARCH_ARM32 0
#define TOML_ARCH_ARM64 0
#define TOML_ARCH_ARM 0
#endif
// TOML_HAS_INCLUDE
@ -898,39 +929,29 @@ TOML_ENABLE_WARNINGS;
TOML_REQUIRES(condition)
#define TOML_HIDDEN_CONSTRAINT(condition, ...) TOML_CONSTRAINED_TEMPLATE(condition, __VA_ARGS__)
// clang-format off
#if TOML_CLANG
#if (TOML_ARCH_ARM || TOML_ARCH_X86 || TOML_ARCH_AMD64) && defined(__FLT16_MANT_DIG__)
#define TOML_FLOAT16 _Float16
#endif
#elif TOML_GCC
/*
#ifdef __FLT16_MANT_DIG__
#if __FLT_RADIX__ == 2 \
&& __FLT16_MANT_DIG__ == 11 \
&& __FLT16_DIG__ == 3 \
&& __FLT16_MIN_EXP__ == -13 \
&& __FLT16_MIN_10_EXP__ == -4 \
&& __FLT16_MAX_EXP__ == 16 \
&& __FLT16_MAX_10_EXP__ == 4
#if TOML_ARM && (TOML_GCC || TOML_CLANG)
#define TOML_FP16 __fp16
#endif
#if TOML_ARM && TOML_CLANG // not present in g++
#define TOML_FLOAT16 _Float16
#endif
#endif
*/
#if (TOML_ARCH_ARM /*|| TOML_ARCH_X86 || TOML_ARCH_AMD64*/) && defined(__FLT16_MANT_DIG__)
#define TOML_FLOAT16 _Float16
#endif
#endif
#if defined(__SIZEOF_FLOAT128__) \
&& defined(__FLT128_MANT_DIG__) \
&& defined(__LDBL_MANT_DIG__) \
#if defined(__SIZEOF_FLOAT128__) && defined(__FLT128_MANT_DIG__) && defined(__LDBL_MANT_DIG__) \
&& __FLT128_MANT_DIG__ > __LDBL_MANT_DIG__
#define TOML_FLOAT128 __float128
#define TOML_FLOAT128 __float128
#endif
#ifdef __SIZEOF_INT128__
#define TOML_INT128 __int128_t
#define TOML_UINT128 __uint128_t
#define TOML_INT128 __int128_t
#define TOML_UINT128 __uint128_t
#endif
// clang-format on
// clang-format off
//******** impl/version.h ********************************************************************************************
@ -1678,11 +1699,6 @@ TOML_IMPL_NAMESPACE_START
template <typename T>
struct float_traits : float_traits_base<T, std::numeric_limits<T>::digits, std::numeric_limits<T>::digits10>
{};
#ifdef TOML_FP16
template <>
struct float_traits<TOML_FP16> : float_traits_base<TOML_FP16, __FLT16_MANT_DIG__, __FLT16_DIG__>
{};
#endif
#ifdef TOML_FLOAT16
template <>
struct float_traits<TOML_FLOAT16> : float_traits_base<TOML_FLOAT16, __FLT16_MANT_DIG__, __FLT16_DIG__>
@ -1704,11 +1720,6 @@ TOML_IMPL_NAMESPACE_START
template <>
struct value_traits<long double> : float_traits<long double>
{};
#ifdef TOML_FP16
template <>
struct value_traits<TOML_FP16> : float_traits<TOML_FP16>
{};
#endif
#ifdef TOML_FLOAT16
template <>
struct value_traits<TOML_FLOAT16> : float_traits<TOML_FLOAT16>
@ -17056,7 +17067,12 @@ TOML_POP_WARNINGS;
#undef TOML_ANON_NAMESPACE
#undef TOML_ANON_NAMESPACE_END
#undef TOML_ANON_NAMESPACE_START
#undef TOML_ARM
#undef TOML_ARCH_ARM
#undef TOML_ARCH_AMD64
#undef TOML_ARCH_ARM32
#undef TOML_ARCH_ARM64
#undef TOML_ARCH_ITANIUM
#undef TOML_ARCH_X86
#undef TOML_ASSERT
#undef TOML_ASSERT_ASSUME
#undef TOML_ASSUME
@ -17093,7 +17109,6 @@ TOML_POP_WARNINGS;
#undef TOML_FLOAT_CHARCONV
#undef TOML_FLOAT128
#undef TOML_FLOAT16
#undef TOML_FP16
#undef TOML_GCC
#undef TOML_HAS_ATTR
#undef TOML_HAS_BUILTIN

28
vendor/catch.hpp vendored
View File

@ -1,6 +1,6 @@
/*
* Catch v2.13.9
* Generated: 2022-04-12 22:37:23.260201
* Catch v2.13.10
* Generated: 2022-10-16 11:01:23.452308
* ----------------------------------------------------------
* This file has been merged from multiple headers. Please don't edit it directly
* Copyright (c) 2022 Two Blue Cubes Ltd. All rights reserved.
@ -15,7 +15,7 @@
#define CATCH_VERSION_MAJOR 2
#define CATCH_VERSION_MINOR 13
#define CATCH_VERSION_PATCH 9
#define CATCH_VERSION_PATCH 10
#ifdef __clang__
# pragma clang system_header
@ -7395,8 +7395,6 @@ namespace Catch {
template <typename T, bool Destruct>
struct ObjectStorage
{
using TStorage = typename std::aligned_storage<sizeof(T), std::alignment_of<T>::value>::type;
ObjectStorage() : data() {}
ObjectStorage(const ObjectStorage& other)
@ -7439,7 +7437,7 @@ namespace Catch {
return *static_cast<T*>(static_cast<void*>(&data));
}
TStorage data;
struct { alignas(T) unsigned char data[sizeof(T)]; } data;
};
}
@ -7949,7 +7947,7 @@ namespace Catch {
#if defined(__i386__) || defined(__x86_64__)
#define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */
#elif defined(__aarch64__)
#define CATCH_TRAP() __asm__(".inst 0xd4200000")
#define CATCH_TRAP() __asm__(".inst 0xd43e0000")
#endif
#elif defined(CATCH_PLATFORM_IPHONE)
@ -13558,7 +13556,7 @@ namespace Catch {
// Handle list request
if( Option<std::size_t> listed = list( m_config ) )
return static_cast<int>( *listed );
return (std::min) (MaxExitCode, static_cast<int>(*listed));
TestGroup tests { m_config };
auto const totals = tests.execute();
@ -15391,7 +15389,7 @@ namespace Catch {
}
Version const& libraryVersion() {
static Version version( 2, 13, 9, "", 0 );
static Version version( 2, 13, 10, "", 0 );
return version;
}
@ -17526,12 +17524,20 @@ namespace Catch {
#ifndef __OBJC__
#ifndef CATCH_INTERNAL_CDECL
#ifdef _MSC_VER
#define CATCH_INTERNAL_CDECL __cdecl
#else
#define CATCH_INTERNAL_CDECL
#endif
#endif
#if defined(CATCH_CONFIG_WCHAR) && defined(CATCH_PLATFORM_WINDOWS) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN)
// Standard C/C++ Win32 Unicode wmain entry point
extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) {
extern "C" int CATCH_INTERNAL_CDECL wmain (int argc, wchar_t * argv[], wchar_t * []) {
#else
// Standard C/C++ main entry point
int main (int argc, char * argv[]) {
int CATCH_INTERNAL_CDECL main (int argc, char * argv[]) {
#endif
return Catch::Session().run( argc, argv );