From ca13eee19faa407764bf64c79e79bf6815ebc3f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Feroldi?= Date: Thu, 20 Jul 2017 16:13:24 -0300 Subject: [PATCH 1/3] 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) { ^ --- fmt/format.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fmt/format.h b/fmt/format.h index a4379da347a1..f4128df14250 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -923,7 +923,11 @@ struct IntTraits { TypeSelector::digits <= 32>::Type MainType; }; +#if FMT_HAS_GXX_CXX11 +FMT_API [[noreturn]] void report_unknown_type(char code, const char *type); +#else FMT_API void report_unknown_type(char code, const char *type); +#endif // Static data is placed in this class template to allow header-only // configuration. From ffa45de992f8d8e2ab2afc14f8e00ba8d1620adb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Feroldi?= Date: Thu, 20 Jul 2017 16:22:49 -0300 Subject: [PATCH 2/3] Check for noreturn attribute availabilty --- fmt/format.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fmt/format.h b/fmt/format.h index f4128df14250..1427218b8bde 100644 --- a/fmt/format.h +++ b/fmt/format.h @@ -923,7 +923,7 @@ struct IntTraits { TypeSelector::digits <= 32>::Type MainType; }; -#if FMT_HAS_GXX_CXX11 +#if FMT_HAS_CPP_ATTRIBUTE(noreturn) FMT_API [[noreturn]] void report_unknown_type(char code, const char *type); #else FMT_API void report_unknown_type(char code, const char *type); From e792f1726b44e02cb201fd714b62844db95554cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rio=20Feroldi?= Date: Fri, 21 Jul 2017 02:24:41 -0300 Subject: [PATCH 3/3] Make MinGW work with noreturn attribute --- fmt/format.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/fmt/format.h b/fmt/format.h index 1427218b8bde..72e7c1bf3a06 100644 --- a/fmt/format.h +++ b/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,11 +932,7 @@ struct IntTraits { TypeSelector::digits <= 32>::Type MainType; }; -#if FMT_HAS_CPP_ATTRIBUTE(noreturn) -FMT_API [[noreturn]] void report_unknown_type(char code, const char *type); -#else -FMT_API void report_unknown_type(char code, const char *type); -#endif +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.