This is an automated email from the ASF dual-hosted git repository. bennoe pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit d5b6ba7f40cb10724d92554f44cae5bfd39ac961 Author: Benno Evers <[email protected]> AuthorDate: Thu Nov 7 14:55:13 2019 +0100 Revamped attribute handling in stout. This makes several changes to the attribute compatibility layer provided by stout: * Add a new `STOUT_HAS_CPP_ATTRIBUTE` macro to test compiler support for a given attribute. * Renamed the non-namespaced `NORETURN` macro to `STOUT_NORETURN`. * Preferred the use of the standardized `[[noreturn]]` syntax if supported by the compiler. * Fixed previous usages of `NORETURN` in the stout codebase. * Added support for the `[[nodiscard]]` attribute. Review: https://reviews.apache.org/r/71734/ --- 3rdparty/stout/include/stout/abort.hpp | 6 ++++-- 3rdparty/stout/include/stout/attributes.hpp | 26 ++++++++++++++++++++++---- 3rdparty/stout/include/stout/exit.hpp | 2 +- 3rdparty/stout/include/stout/unimplemented.hpp | 2 +- 3rdparty/stout/include/stout/unreachable.hpp | 2 +- 5 files changed, 29 insertions(+), 9 deletions(-) diff --git a/3rdparty/stout/include/stout/abort.hpp b/3rdparty/stout/include/stout/abort.hpp index 43ed5ce..1917106 100644 --- a/3rdparty/stout/include/stout/abort.hpp +++ b/3rdparty/stout/include/stout/abort.hpp @@ -40,7 +40,8 @@ #define ABORT(...) _Abort(_ABORT_PREFIX, __VA_ARGS__) -inline NORETURN void _Abort(const char* prefix, const char* message) +STOUT_NORETURN +inline void _Abort(const char* prefix, const char* message) { #ifndef __WINDOWS__ const size_t prefix_len = strlen(prefix); @@ -87,7 +88,8 @@ inline NORETURN void _Abort(const char* prefix, const char* message) } -inline NORETURN void _Abort(const char* prefix, const std::string& message) +STOUT_NORETURN +inline void _Abort(const char* prefix, const std::string& message) { _Abort(prefix, message.c_str()); } diff --git a/3rdparty/stout/include/stout/attributes.hpp b/3rdparty/stout/include/stout/attributes.hpp index aa377db..a02ee79 100644 --- a/3rdparty/stout/include/stout/attributes.hpp +++ b/3rdparty/stout/include/stout/attributes.hpp @@ -13,12 +13,30 @@ #ifndef __STOUT_ATTRIBUTES_HPP__ #define __STOUT_ATTRIBUTES_HPP__ +#ifdef __has_cpp_attribute +# define STOUT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) +#else +# define STOUT_HAS_CPP_ATTRIBUTE(x) 0 +#endif -#ifdef __WINDOWS__ -#define NORETURN __declspec(noreturn) +// We unconditionally require compiler support for `noreturn`, +// both for legacy reasons and because the presence of this +// attribute might affect code generation. +#if STOUT_HAS_CPP_ATTRIBUTE(noreturn) > 0 +# define STOUT_NORETURN [[noreturn]] +#elif defined(__WINDOWS__) +# define STOUT_NORETURN __declspec(noreturn) #else -#define NORETURN __attribute__((noreturn)) -#endif // __WINDOWS__ +# define STOUT_NORETURN __attribute__((noreturn)) +#endif + +// Non-namespaced version for backwards compatibility. +#define NORETURN STOUT_NORETURN +#if STOUT_HAS_CPP_ATTRIBUTE(nodiscard) > 0 +# define STOUT_NODISCARD [[nodiscard]] +#else +# define STOUT_NODISCARD +#endif #endif // __STOUT_ATTRIBUTES_HPP__ diff --git a/3rdparty/stout/include/stout/exit.hpp b/3rdparty/stout/include/stout/exit.hpp index 34585a0..25721d4 100644 --- a/3rdparty/stout/include/stout/exit.hpp +++ b/3rdparty/stout/include/stout/exit.hpp @@ -62,7 +62,7 @@ struct __Exit stream() << "EXIT with status " << _status << ": "; } - NORETURN ~__Exit() + STOUT_NORETURN ~__Exit() { message.Flush(); exit(status); diff --git a/3rdparty/stout/include/stout/unimplemented.hpp b/3rdparty/stout/include/stout/unimplemented.hpp index ab6caa8..168a2f8 100644 --- a/3rdparty/stout/include/stout/unimplemented.hpp +++ b/3rdparty/stout/include/stout/unimplemented.hpp @@ -28,7 +28,7 @@ #define UNIMPLEMENTED Unimplemented(__func__, __FILE__, __LINE__) -NORETURN inline void Unimplemented( +STOUT_NORETURN inline void Unimplemented( const char* function, const char* file, const int line) diff --git a/3rdparty/stout/include/stout/unreachable.hpp b/3rdparty/stout/include/stout/unreachable.hpp index d4b3bb0..e33bc01 100644 --- a/3rdparty/stout/include/stout/unreachable.hpp +++ b/3rdparty/stout/include/stout/unreachable.hpp @@ -22,7 +22,7 @@ #define UNREACHABLE() Unreachable(__FILE__, __LINE__) -inline NORETURN void Unreachable(const char* file, int line) +STOUT_NORETURN inline void Unreachable(const char* file, int line) { std::cerr << "Reached unreachable statement at " << file << ':' << line << std::endl;
