From f81054d5ce0538e35dcdbf6d9bad66095cb21e72 Mon Sep 17 00:00:00 2001 From: Ronen Friedman Date: Sun, 5 Jan 2020 08:23:58 +0200 Subject: [PATCH] crimson: fix non-standard C++ constructs in errorator.h Fixing use patterns accepted by gcc, but frowned upon by Clang: Put noexcept specifier after attributes specifiers (as per the C++ standard $11.3.5) Limit the use of a not-completely-defined class names to within function bodies, per the standard ("A class is considered a completely-defined object type (or complete type) at the closing } of the class-specifier. Within the class member-specification, the class is regarded as complete within function bodies, default arguments, noexcept-specifiers, and default member initializers (including such things in nested classes). Otherwise it is regarded as incomplete within its own class member-specification.") Signed-off-by: Ronen Friedman --- src/crimson/common/errorator.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/crimson/common/errorator.h b/src/crimson/common/errorator.h index 1501999e74ed..f3911204b41c 100644 --- a/src/crimson/common/errorator.h +++ b/src/crimson/common/errorator.h @@ -79,8 +79,8 @@ public: template struct unthrowable_wrapper : error_t> { unthrowable_wrapper(const unthrowable_wrapper&) = delete; - static const unthrowable_wrapper instance; [[nodiscard]] static const auto& make() { + static constexpr unthrowable_wrapper instance{}; return instance; } @@ -118,13 +118,11 @@ private: return carrier_instance; } static const auto& from_exception_ptr(std::exception_ptr) { - return instance; + return make(); } friend class error_t>; }; -template -const inline unthrowable_wrapper unthrowable_wrapper::instance{}; template std::exception_ptr unthrowable_wrapper::carrier_instance = \ @@ -481,7 +479,7 @@ private: return this->then_wrapped( [ valfunc = std::forward(valfunc), errfunc = std::forward(errfunc) - ] (auto&& future) mutable [[gnu::always_inline]] noexcept { + ] (auto&& future) mutable noexcept [[gnu::always_inline]] { if (__builtin_expect(future.failed(), false)) { return _safe_then_handle_errors( std::move(future), std::forward(errfunc)); @@ -530,7 +528,7 @@ private: return this->then_wrapped( [ func = std::forward(func) - ] (auto&& future) mutable [[gnu::always_inline]] noexcept { + ] (auto&& future) mutable noexcept [[gnu::always_inline]] { return futurator_t::apply(std::forward(func)).safe_then( [future = std::forward(future)]() mutable { return std::move(future); @@ -574,7 +572,7 @@ private: typename return_errorator_t::template futurize<::seastar::future>; return this->then_wrapped( [ errfunc = std::forward(errfunc) - ] (auto&& future) mutable [[gnu::always_inline]] noexcept { + ] (auto&& future) mutable noexcept [[gnu::always_inline]] { if (__builtin_expect(future.failed(), false)) { return _safe_then_handle_errors( std::move(future), std::forward(errfunc)); -- 2.47.3