From ca2091a884b47e2bafdb5eba80cf0bf7e9881799 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Mon, 6 Jan 2020 09:41:47 +0100 Subject: [PATCH] Add BOOST_NOWIDE_FALLTHROUGH for Boost < 1.64 --- include/boost/nowide/config.hpp | 7 +++++++ include/boost/nowide/detail/utf.hpp | 10 +++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/boost/nowide/config.hpp b/include/boost/nowide/config.hpp index 40db464..63de44d 100644 --- a/include/boost/nowide/config.hpp +++ b/include/boost/nowide/config.hpp @@ -13,6 +13,7 @@ #include #include +#include #if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_NOWIDE_DYN_LINK) #ifdef BOOST_NOWIDE_SOURCE @@ -63,5 +64,11 @@ #define BOOST_NOWIDE_USE_FSTREAM_REPLACEMENTS 0 #endif +#if BOOST_VERSION < 106500 && defined(BOOST_GCC) && BOOST_GCC_VERSION >= 70000 +#define BOOST_NOWIDE_FALLTHROUGH __attribute__((fallthrough)) +#else +#define BOOST_NOWIDE_FALLTHROUGH BOOST_FALLTHROUGH +#endif + #endif // boost/nowide/config.hpp // vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 diff --git a/include/boost/nowide/detail/utf.hpp b/include/boost/nowide/detail/utf.hpp index 28bd7f0..ed43980 100644 --- a/include/boost/nowide/detail/utf.hpp +++ b/include/boost/nowide/detail/utf.hpp @@ -8,7 +8,7 @@ #ifndef BOOST_NOWIDE_UTF_HPP_INCLUDED #define BOOST_NOWIDE_UTF_HPP_INCLUDED -#include +#include #include namespace boost { @@ -219,7 +219,7 @@ namespace nowide { if(!is_trail(tmp)) return illegal; c = (c << 6) | (tmp & 0x3F); - BOOST_FALLTHROUGH; + BOOST_NOWIDE_FALLTHROUGH; case 2: if(BOOST_UNLIKELY(p == e)) return incomplete; @@ -227,7 +227,7 @@ namespace nowide { if(!is_trail(tmp)) return illegal; c = (c << 6) | (tmp & 0x3F); - BOOST_FALLTHROUGH; + BOOST_NOWIDE_FALLTHROUGH; case 1: if(BOOST_UNLIKELY(p == e)) return incomplete; @@ -269,8 +269,8 @@ namespace nowide { switch(trail_size) { - case 3: c = (c << 6) | (static_cast(*p++) & 0x3F); BOOST_FALLTHROUGH; - case 2: c = (c << 6) | (static_cast(*p++) & 0x3F); BOOST_FALLTHROUGH; + case 3: c = (c << 6) | (static_cast(*p++) & 0x3F); BOOST_NOWIDE_FALLTHROUGH; + case 2: c = (c << 6) | (static_cast(*p++) & 0x3F); BOOST_NOWIDE_FALLTHROUGH; case 1: c = (c << 6) | (static_cast(*p++) & 0x3F); }