[PATCH] D45179: [libc++] Add _LIBCPP_FORCE_NODISCARD define to force-enable nodiscard in pre-C++17

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 24 11:01:18 PDT 2018


lebedev.ri added inline comments.


================
Comment at: include/__config:1016
+// because GCC does not silence them via (void) cast.
+#if __has_cpp_attribute(nodiscard) && _LIBCPP_STD_VER > 17
+#  define _LIBCPP_NODISCARD [[nodiscard]]
----------------
mclow.lists wrote:
> `[[nodiscard]]` is a C++17 feature. This test should be `>=`, not `>`.
Indeed, though the left hand side of the diff already specified `_LIBCPP_STD_VER > 17`.
Interesting, isn't it.


================
Comment at: include/__config:1026
+    (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_FORCE_NODISCARD))
+#  define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
 #else
----------------
mclow.lists wrote:
> I wouldn't change this; just leave it as `[[nodiscard]]`
But that would defy the purpose?


Repository:
  rCXX libc++

https://reviews.llvm.org/D45179





More information about the cfe-commits mailing list