Add support for __unreachable_return on clang and GCC.

See https://svn.boost.org/trac/boost/ticket/11661.
This commit is contained in:
jzmaddock
2015-09-16 18:27:48 +01:00
parent ca01235304
commit a17884f425
3 changed files with 16 additions and 4 deletions

View File

@ -255,6 +255,11 @@
// All versions with __cplusplus above this value seem to support this: // All versions with __cplusplus above this value seem to support this:
# define BOOST_NO_CXX14_DIGIT_SEPARATORS # define BOOST_NO_CXX14_DIGIT_SEPARATORS
#endif #endif
//
// __builtin_unreachable:
#if defined(__has_builtin) && __has_builtin(__builtin_unreachable)
#define BOOST_UNREACHABLE_RETURN(x) __builtin_unreachable();
#endif
// Unused attribute: // Unused attribute:

View File

@ -278,6 +278,11 @@
#if __GNUC__ >= 4 #if __GNUC__ >= 4
# define BOOST_ATTRIBUTE_UNUSED __attribute__((unused)) # define BOOST_ATTRIBUTE_UNUSED __attribute__((unused))
#endif #endif
//
// __builtin_unreachable:
#if BOOST_GCC_VERSION >= 40800
#define BOOST_UNREACHABLE_RETURN(x) __builtin_unreachable();
#endif
#ifndef BOOST_COMPILER #ifndef BOOST_COMPILER
# define BOOST_COMPILER "GNU C++ version " __VERSION__ # define BOOST_COMPILER "GNU C++ version " __VERSION__

View File

@ -444,10 +444,12 @@ namespace std {
// is defined, in which case it evaluates to return x; Use when you have a return // is defined, in which case it evaluates to return x; Use when you have a return
// statement that can never be reached. // statement that can never be reached.
#ifdef BOOST_NO_UNREACHABLE_RETURN_DETECTION #ifndef BOOST_UNREACHABLE_RETURN
# define BOOST_UNREACHABLE_RETURN(x) return x; # ifdef BOOST_NO_UNREACHABLE_RETURN_DETECTION
#else # define BOOST_UNREACHABLE_RETURN(x) return x;
# define BOOST_UNREACHABLE_RETURN(x) # else
# define BOOST_UNREACHABLE_RETURN(x)
# endif
#endif #endif
// BOOST_DEDUCED_TYPENAME workaround ------------------------------------------// // BOOST_DEDUCED_TYPENAME workaround ------------------------------------------//