From b272fb360580702aca152d3a634dddf34e379660 Mon Sep 17 00:00:00 2001 From: Federico <55920584+federico-busato@users.noreply.github.com> Date: Wed, 11 Dec 2019 23:28:20 +0100 Subject: [PATCH] Extend FMT_FALLTHROUGH compatibily to gcc and clang pre-C++17 (#1469) --- include/fmt/format.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index 01f41f5c..5109368e 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -69,9 +69,17 @@ # define FMT_HAS_BUILTIN(x) 0 #endif -#if FMT_HAS_CPP_ATTRIBUTE(fallthrough) && \ - (__cplusplus >= 201703 || FMT_GCC_VERSION != 0) -# define FMT_FALLTHROUGH [[fallthrough]] +#if __cplusplus == 201103L || __cplusplus == 201402L +# if defined(__clang__) +# define FMT_FALLTHROUGH [[clang::fallthrough]]; +# elif FMT_GCC_VERSION >= 700 +# define FMT_FALLTHROUGH [[gnu::fallthrough]]; +# else +# define FMT_FALLTHROUGH +# endif +#elif FMT_HAS_CPP_ATTRIBUTE(fallthrough) && \ + ((__cplusplus >= 201703) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)) +# define FMT_FALLTHROUGH [[fallthrough]]; #else # define FMT_FALLTHROUGH #endif