[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:14:46 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:
> lebedev.ri wrote:
> > 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.
> That was because the flag `_LIBCPP_NODISCARD_AFTER_CXX17` was only active post-c++17.
>
> Now we're talking about doing stuff in earlier standards, we should use `[[nodiscard]]` for C++17
Oh, right, sorry!
================
Comment at: include/__config:1026
+ (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_FORCE_NODISCARD))
+# define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD
#else
----------------
mclow.lists wrote:
> lebedev.ri wrote:
> > mclow.lists wrote:
> > > I wouldn't change this; just leave it as `[[nodiscard]]`
> > But that would defy the purpose?
> That's a fair point - but I don't want this to be anything but `[[nodiscard]]` if we're compiling for C++2a or later.
>
> I don't want this to be anything but [[nodiscard]] **if we're compiling for C++2a or later**.
Aha, i see, ok.
Repository:
rCXX libc++
https://reviews.llvm.org/D45179
More information about the cfe-commits
mailing list