mirror of
https://github.com/fmtlib/fmt.git
synced 2025-12-07 09:16:53 +08:00
Suppress warning about missing noreturn attribute (#549)
Suppress warning about missing noreturn attribute
Adding `[[noreturn]]` to `report_unknown_type` suppresses the Clang/GCC `-Wmissing-noreturn` warning:
Clang outputs:
.../fmt/fmt/format.cc:294:74: warning:
function 'report_unknown_type' could be declared with
attribute 'noreturn' [-Wmissing-noreturn]
...code, const char *type) {
^
GCC outputs:
.../fmt/fmt/format.cc:294:74: warning: function might be candidate for
attribute 'noreturn' [-Wsuggest-attribute=noreturn]
...code, const char *type) {
^
This commit is contained in:
parent
9c56a8ce5c
commit
d16c4d20f8
11
fmt/format.h
11
fmt/format.h
@ -139,6 +139,15 @@ typedef __int64 intmax_t;
|
||||
# define FMT_HAS_CPP_ATTRIBUTE(x) 0
|
||||
#endif
|
||||
|
||||
// Use the compiler's attribute noreturn
|
||||
#if defined(__MINGW32__) || defined(__MINGW64__)
|
||||
# define FMT_NORETURN __attribute__((noreturn))
|
||||
#elif FMT_HAS_CPP_ATTRIBUTE(noreturn)
|
||||
# define FMT_NORETURN [[noreturn]]
|
||||
#else
|
||||
# define FMT_NORETURN
|
||||
#endif
|
||||
|
||||
#ifndef FMT_USE_VARIADIC_TEMPLATES
|
||||
// Variadic templates are available in GCC since version 4.4
|
||||
// (http://gcc.gnu.org/projects/cxx0x.html) and in Visual C++
|
||||
@ -923,7 +932,7 @@ struct IntTraits {
|
||||
TypeSelector<std::numeric_limits<T>::digits <= 32>::Type MainType;
|
||||
};
|
||||
|
||||
FMT_API void report_unknown_type(char code, const char *type);
|
||||
FMT_API FMT_NORETURN void report_unknown_type(char code, const char *type);
|
||||
|
||||
// Static data is placed in this class template to allow header-only
|
||||
// configuration.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user