From da439f28388971fc77da435a9a3cd761a94fee23 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 23 Jul 2017 20:21:11 -0700 Subject: [PATCH] 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) { ^ Cherry-picked d16c4d. --- fmt/format.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fmt/format.h b/fmt/format.h index 96f9d3c7..85f396b9 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -137,6 +137,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_RVALUE_REFERENCES // Don't use rvalue references when compiling with clang and an old libstdc++ // as the latter doesn't provide std::move. @@ -855,7 +864,7 @@ struct int_traits { std::numeric_limits::digits <= 32, uint32_t, uint64_t>::type main_type; }; -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.