Quuxplusone added a comment. In https://reviews.llvm.org/D45179#1064589, @lebedev.ri wrote:
> I'm waiting for @mclow.lists to have the final say re this differential. Ack. :) > So roughly: > > // NOTE: Do not use [[nodiscard]] in pre-C++17 mode > // to avoid -Wc++17-extensions warning. > // And we can't use GCC's [[gnu::warn_unused_result]] and > // __attribute__((warn_unused_result)), > // because GCC does not silence them via (void) cast. > #if !defined(_LIBCPP_NODISCARD) > # if __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17 > # define _LIBCPP_NODISCARD [[nodiscard]] > # elif __has_cpp_attribute(clang::warn_unused_result) > # define _LIBCPP_NODISCARD [[clang::warn_unused_result]] > # else > # define _LIBCPP_NODISCARD > # endif > #endif > > > ? Yes, that correctly expresses my intent. Personally I would write it like this to reduce the nesting and linecount: // NOTE: Do not use [[nodiscard]] in pre-C++17 mode // to avoid -Wc++17-extensions warning. // And we can't use GCC's [[gnu::warn_unused_result]] and // __attribute__((warn_unused_result)), // because GCC does not silence them via (void) cast. #if defined(_LIBCPP_NODISCARD) #elif __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17 # define _LIBCPP_NODISCARD [[nodiscard]] #elif __has_cpp_attribute(clang::warn_unused_result) # define _LIBCPP_NODISCARD [[clang::warn_unused_result]] #else # define _LIBCPP_NODISCARD #endif Repository: rCXX libc++ https://reviews.llvm.org/D45179 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits