Add FMT_HAS_CPP14_ATTRIBUTE / FMT_HAS_CPP17_ATTRIBUTE to test for language-specific attributes.

FMT_DEPRECATED is now defined as FMT_HAS_CPP14_ATTRIBUTE(deprecated), as this attribute was introduced in C++14.

FMT_FALLTHROUGH is now defined as FMT_HAS_CPP17_ATTRIBUTE(fallthrough), as this attribute was introduced in C++17.

FMT_MAYBE_UNUSED is defined as FMT_HAS_CPP17_ATTRIBUTE(maybe_unused), as this attribute was introduced in C++17.

FMT_MAYBE_UNUSED has been applied to fix a couple of -Wunused-member-function warnings from clang.
This commit is contained in:
Dair Grant
2020-03-02 14:51:51 +00:00
committed by Victor Zverovich
parent 3c24052cf1
commit 02bfd8a9a5
3 changed files with 20 additions and 4 deletions

View File

@@ -71,7 +71,7 @@
# else
# define FMT_FALLTHROUGH
# endif
#elif (FMT_HAS_CPP_ATTRIBUTE(fallthrough) && (__cplusplus >= 201703)) || \
#elif FMT_HAS_CPP17_ATTRIBUTE(fallthrough) || \
(defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
# define FMT_FALLTHROUGH [[fallthrough]]
#else
@@ -3549,7 +3549,7 @@ FMT_END_NAMESPACE
/* Use a macro-like name to avoid shadowing warnings. */ \
struct FMT_COMPILE_STRING : fmt::compile_string { \
using char_type = fmt::remove_cvref_t<decltype(*s)>; \
__VA_ARGS__ FMT_CONSTEXPR \
FMT_MAYBE_UNUSED __VA_ARGS__ FMT_CONSTEXPR \
operator fmt::basic_string_view<char_type>() const { \
/* FMT_STRING only accepts string literals. */ \
return fmt::internal::literal_to_view(s); \