mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-09 21:00:06 +00:00
Avoid a space in the UDL definition (#3610)
* Avoid a space in the UDL definition except on GCC before 4.9 Clang 18 has grown a warning about the space being deprecated which is enabled by default in their nightly binaries. However GCC before 4.9 will reject the UDL definition unless there is a space there, so we need to keep the space conditionally for it. * Remove UDLs on GCC before 4.9 to simplify things GCC before 4.9 rejects the syntax that is now rejected on more modern compilers. * Disable compile-error-test on GCC < 4.9 This avoids the UDL tests failing as GCC < 4.9 can not parse UDLs without a space, but the space is malformed in modern compilers.
This commit is contained in:
parent
a8a73da7e4
commit
f6ca4ea199
@ -153,7 +153,10 @@ FMT_END_NAMESPACE
|
||||
|
||||
#ifndef FMT_USE_USER_DEFINED_LITERALS
|
||||
// EDG based compilers (Intel, NVIDIA, Elbrus, etc), GCC and MSVC support UDLs.
|
||||
# if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION >= 407 || \
|
||||
//
|
||||
// GCC before 4.9 requires a space in `operator"" _a` which is invalid in later
|
||||
// compiler versions.
|
||||
# if (FMT_HAS_FEATURE(cxx_user_literals) || FMT_GCC_VERSION >= 409 || \
|
||||
FMT_MSC_VERSION >= 1900) && \
|
||||
(!defined(__EDG_VERSION__) || __EDG_VERSION__ >= /* UDL feature */ 480)
|
||||
# define FMT_USE_USER_DEFINED_LITERALS 1
|
||||
@ -4459,7 +4462,7 @@ template <detail_exported::fixed_string Str> constexpr auto operator""_a() {
|
||||
return detail::udl_arg<char_t, sizeof(Str.data) / sizeof(char_t), Str>();
|
||||
}
|
||||
# else
|
||||
constexpr auto operator"" _a(const char* s, size_t) -> detail::udl_arg<char> {
|
||||
constexpr auto operator""_a(const char* s, size_t) -> detail::udl_arg<char> {
|
||||
return {s};
|
||||
}
|
||||
# endif
|
||||
|
@ -175,7 +175,12 @@ if (FMT_PEDANTIC)
|
||||
endif ()
|
||||
|
||||
# These tests are disabled on Windows because they take too long.
|
||||
if (FMT_PEDANTIC AND NOT WIN32)
|
||||
# They are disabled on GCC < 4.9 because it can not parse UDLs without
|
||||
# a space after `operator""` but that is an incorrect syntax for any more
|
||||
# modern compiler.
|
||||
if (FMT_PEDANTIC AND NOT WIN32 AND NOT (
|
||||
CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND
|
||||
CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9))
|
||||
# Test if incorrect API usages produce compilation error.
|
||||
add_test(compile-error-test ${CMAKE_CTEST_COMMAND}
|
||||
--build-and-test
|
||||
|
Loading…
Reference in New Issue
Block a user