mirror of
https://github.com/shadps4-emu/ext-fmt.git
synced 2025-03-03 15:48:47 +00:00
Cleanup conseval detection
This commit is contained in:
parent
b71d98774b
commit
52174953bc
@ -54,24 +54,6 @@
|
||||
# define FMT_LIBCPP_VERSION 0
|
||||
#endif
|
||||
|
||||
// Check if exceptions are disabled.
|
||||
#ifdef FMT_EXCEPTIONS
|
||||
// Use the provided definition.
|
||||
#elif defined(__GNUC__) && !defined(__EXCEPTIONS)
|
||||
# define FMT_EXCEPTIONS 0
|
||||
#elif FMT_MSC_VERSION && !_HAS_EXCEPTIONS
|
||||
# define FMT_EXCEPTIONS 0
|
||||
#else
|
||||
# define FMT_EXCEPTIONS 1
|
||||
#endif
|
||||
#if FMT_EXCEPTIONS
|
||||
# define FMT_TRY try
|
||||
# define FMT_CATCH(x) catch (x)
|
||||
#else
|
||||
# define FMT_TRY if (true)
|
||||
# define FMT_CATCH(x) if (false)
|
||||
#endif
|
||||
|
||||
#ifdef _MSVC_LANG
|
||||
# define FMT_CPLUSPLUS _MSVC_LANG
|
||||
#else
|
||||
@ -121,49 +103,54 @@
|
||||
# define FMT_CONSTEXPR
|
||||
#endif
|
||||
|
||||
// Detect C++20 extensions to constexpr and std::is_constant_evaluated.
|
||||
#ifndef __cpp_lib_is_constant_evaluated
|
||||
# define FMT_CONSTEXPR20
|
||||
// Detect consteval, C++20 constexpr extensions and std::is_constant_evaluated.
|
||||
#if !defined(__cpp_lib_is_constant_evaluated)
|
||||
# define FMT_USE_CONSTEVAL 0
|
||||
#elif FMT_CPLUSPLUS < 201709L
|
||||
# define FMT_USE_CONSTEVAL 0
|
||||
#elif FMT_GLIBCXX_RELEASE && FMT_GLIBCXX_RELEASE < 10
|
||||
# define FMT_CONSTEXPR20
|
||||
# define FMT_USE_CONSTEVAL 0
|
||||
#elif FMT_LIBCPP_VERSION && FMT_LIBCPP_VERSION < 10000
|
||||
# define FMT_CONSTEXPR20
|
||||
#elif FMT_MSC_VERSION && FMT_MSC_VERSION < 1928
|
||||
# define FMT_CONSTEXPR20
|
||||
#elif FMT_CPLUSPLUS >= 202002L
|
||||
# define FMT_CONSTEXPR20 constexpr
|
||||
#elif FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002
|
||||
# define FMT_USE_CONSTEVAL 0
|
||||
#elif defined(__apple_build_version__) && __apple_build_version__ < 14000029L
|
||||
# define FMT_USE_CONSTEVAL 0 // consteval is broken in Apple clang < 14.
|
||||
#elif FMT_MSC_VERSION && FMT_MSC_VERSION < 1929
|
||||
# define FMT_USE_CONSTEVAL 0 // consteval is broken in MSVC VS2019 < 16.10.
|
||||
#elif defined(__cpp_consteval)
|
||||
# define FMT_USE_CONSTEVAL 1
|
||||
#elif FMT_GCC_VERSION >= 1002 || FMT_CLANG_VERSION >= 1101
|
||||
# define FMT_USE_CONSTEVAL 1
|
||||
#else
|
||||
# define FMT_USE_CONSTEVAL 0
|
||||
#endif
|
||||
#if FMT_USE_CONSTEVAL
|
||||
# define FMT_CONSTEVAL consteval
|
||||
# define FMT_CONSTEXPR20 constexpr
|
||||
#else
|
||||
# define FMT_CONSTEVAL
|
||||
# define FMT_CONSTEXPR20
|
||||
#endif
|
||||
|
||||
#ifndef FMT_CONSTEVAL
|
||||
# if ((FMT_GCC_VERSION >= 1000 || FMT_CLANG_VERSION >= 1101) && \
|
||||
(!defined(__apple_build_version__) || \
|
||||
__apple_build_version__ >= 14000029L) && \
|
||||
FMT_CPLUSPLUS >= 202002L) || \
|
||||
(defined(__cpp_consteval) && \
|
||||
(!FMT_MSC_VERSION || FMT_MSC_VERSION >= 1929))
|
||||
// consteval is broken in MSVC before VS2019 version 16.10 and Apple clang
|
||||
// before 14.
|
||||
# define FMT_CONSTEVAL consteval
|
||||
# define FMT_HAS_CONSTEVAL
|
||||
# else
|
||||
# define FMT_CONSTEVAL
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef FMT_DEPRECATED
|
||||
// Check if exceptions are disabled.
|
||||
#ifdef FMT_EXCEPTIONS
|
||||
// Use the provided definition.
|
||||
#elif FMT_HAS_CPP14_ATTRIBUTE(deprecated)
|
||||
# define FMT_DEPRECATED [[deprecated]]
|
||||
#elif defined(__GNUC__) && !defined(__EXCEPTIONS)
|
||||
# define FMT_EXCEPTIONS 0
|
||||
#elif FMT_MSC_VERSION && !_HAS_EXCEPTIONS
|
||||
# define FMT_EXCEPTIONS 0
|
||||
#else
|
||||
# define FMT_DEPRECATED /* deprecated */
|
||||
# define FMT_EXCEPTIONS 1
|
||||
#endif
|
||||
#if FMT_EXCEPTIONS
|
||||
# define FMT_TRY try
|
||||
# define FMT_CATCH(x) catch (x)
|
||||
#else
|
||||
# define FMT_TRY if (true)
|
||||
# define FMT_CATCH(x) if (false)
|
||||
#endif
|
||||
|
||||
// Disable [[noreturn]] on MSVC/NVCC because of bogus unreachable code warnings.
|
||||
#if FMT_EXCEPTIONS && FMT_HAS_CPP_ATTRIBUTE(noreturn) && !FMT_MSC_VERSION && \
|
||||
#if FMT_HAS_CPP_ATTRIBUTE(noreturn) && FMT_EXCEPTIONS && !FMT_MSC_VERSION && \
|
||||
!defined(__NVCC__)
|
||||
# define FMT_NORETURN [[noreturn]]
|
||||
#else
|
||||
@ -178,6 +165,14 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef FMT_DEPRECATED
|
||||
// Use the provided definition.
|
||||
#elif FMT_HAS_CPP14_ATTRIBUTE(deprecated)
|
||||
# define FMT_DEPRECATED [[deprecated]]
|
||||
#else
|
||||
# define FMT_DEPRECATED /* deprecated */
|
||||
#endif
|
||||
|
||||
#ifdef FMT_INLINE
|
||||
// Use the provided definition.
|
||||
#elif FMT_GCC_VERSION || FMT_CLANG_VERSION
|
||||
@ -186,6 +181,12 @@
|
||||
# define FMT_INLINE inline
|
||||
#endif
|
||||
|
||||
#if FMT_GCC_VERSION || FMT_CLANG_VERSION
|
||||
# define FMT_VISIBILITY(value) __attribute__((visibility(value)))
|
||||
#else
|
||||
# define FMT_VISIBILITY(value)
|
||||
#endif
|
||||
|
||||
#ifndef FMT_GCC_PRAGMA
|
||||
// Workaround a _Pragma bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59884
|
||||
// and an nvhpc warning: https://github.com/fmtlib/fmt/pull/2582.
|
||||
@ -195,16 +196,13 @@
|
||||
# define FMT_GCC_PRAGMA(arg)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if FMT_MSC_VERSION
|
||||
# define FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__))
|
||||
#else
|
||||
# define FMT_MSC_WARNING(...)
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# define FMT_UNCHECKED_ITERATOR(It) \
|
||||
using _Unchecked_type = It // Mark iterator as checked.
|
||||
#else
|
||||
# define FMT_MSC_WARNING(...)
|
||||
# define FMT_UNCHECKED_ITERATOR(It) using unchecked_type = It
|
||||
#endif
|
||||
|
||||
@ -223,12 +221,6 @@
|
||||
# define FMT_END_EXPORT
|
||||
#endif
|
||||
|
||||
#if FMT_GCC_VERSION || FMT_CLANG_VERSION
|
||||
# define FMT_VISIBILITY(value) __attribute__((visibility(value)))
|
||||
#else
|
||||
# define FMT_VISIBILITY(value)
|
||||
#endif
|
||||
|
||||
#if !defined(FMT_HEADER_ONLY) && defined(_WIN32)
|
||||
# if defined(FMT_LIB_EXPORT)
|
||||
# define FMT_API __declspec(dllexport)
|
||||
@ -1272,7 +1264,7 @@ template <typename Context> class value {
|
||||
template <typename T> FMT_CONSTEXPR20 FMT_INLINE value(T& val) {
|
||||
using value_type = remove_const_t<T>;
|
||||
// T may overload operator& e.g. std::vector<bool>::reference in libc++.
|
||||
#ifdef __cpp_if_constexpr
|
||||
#if defined(__cpp_if_constexpr)
|
||||
if constexpr (std::is_same<decltype(&val), T*>::value)
|
||||
custom.value = const_cast<value_type*>(&val);
|
||||
#endif
|
||||
@ -2749,7 +2741,7 @@ template <typename Char, typename... Args> class basic_format_string {
|
||||
(std::is_base_of<detail::view, remove_reference_t<Args>>::value &&
|
||||
std::is_reference<Args>::value)...>() == 0,
|
||||
"passing views as lvalues is disallowed");
|
||||
#ifdef FMT_HAS_CONSTEVAL
|
||||
#if FMT_USE_CONSTEVAL
|
||||
if constexpr (detail::count_named_args<Args...>() ==
|
||||
detail::count_statically_named_args<Args...>()) {
|
||||
using checker =
|
||||
|
@ -8,10 +8,7 @@
|
||||
#include "fmt/compile.h"
|
||||
#include "gmock/gmock.h"
|
||||
|
||||
#if defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806 && \
|
||||
defined(__cpp_constexpr) && __cpp_constexpr >= 201907 && \
|
||||
defined(__cpp_constexpr_dynamic_alloc) && \
|
||||
__cpp_constexpr_dynamic_alloc >= 201907 && FMT_CPLUSPLUS >= 202002L
|
||||
#if FMT_USE_CONSTEVAL
|
||||
|
||||
template <size_t max_string_length, typename Char = char> struct test_string {
|
||||
template <typename T> constexpr bool operator==(const T& rhs) const noexcept {
|
||||
@ -60,4 +57,5 @@ TEST(compile_time_formatting_test, floating_point) {
|
||||
EXPECT_EQ("+inf", test_format<5>(FMT_COMPILE("{:+}"), inf));
|
||||
EXPECT_EQ("-inf", test_format<5>(FMT_COMPILE("{}"), -inf));
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // FMT_USE_CONSTEVAL
|
||||
|
@ -290,18 +290,15 @@ TEST(compile_test, compile_format_string_literal) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// MSVS 2019 19.29.30145.0 - Support C++20 and OK.
|
||||
// MSVS 2019 19.29.30145.0 - OK
|
||||
// MSVS 2022 19.32.31332.0, 19.37.32826.1 - compile-test.cc(362,3): fatal error
|
||||
// C1001: Internal compiler error.
|
||||
// (compiler file
|
||||
// 'D:\a\_work\1\s\src\vctools\Compiler\CxxFE\sl\p1\c\constexpr\constexpr.cpp',
|
||||
// line 8635)
|
||||
#if (FMT_CPLUSPLUS >= 202002L || \
|
||||
(FMT_CPLUSPLUS >= 201709L && FMT_GCC_VERSION >= 1002)) && \
|
||||
((!FMT_GLIBCXX_RELEASE || FMT_GLIBCXX_RELEASE >= 10) && \
|
||||
(!defined(_LIBCPP_VERSION) || _LIBCPP_VERSION >= 10000) && \
|
||||
(!FMT_MSC_VERSION || \
|
||||
(FMT_MSC_VERSION >= 1928 && FMT_MSC_VERSION < 1930))) && \
|
||||
#if FMT_USE_CONSTEVAL && \
|
||||
(!FMT_MSC_VERSION || \
|
||||
(FMT_MSC_VERSION >= 1928 && FMT_MSC_VERSION < 1930)) && \
|
||||
defined(__cpp_lib_is_constant_evaluated)
|
||||
template <size_t max_string_length, typename Char = char> struct test_string {
|
||||
template <typename T> constexpr bool operator==(const T& rhs) const noexcept {
|
||||
|
Loading…
x
Reference in New Issue
Block a user