diff --git a/libcxx/docs/ReleaseNotes.rst b/libcxx/docs/ReleaseNotes.rst --- a/libcxx/docs/ReleaseNotes.rst +++ b/libcxx/docs/ReleaseNotes.rst @@ -148,6 +148,9 @@ will be removed in LLVM 17. You can disable the deprecation warnings by defining ``_LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_SEARCHERS``. +- Extended applications of ``[[nodiscard]]`` are now enabled by default. They can be + disabled by defining ``_LIBCPP_DISBALE_NODISCARD``. + ABI Changes ----------- diff --git a/libcxx/docs/UsingLibcxx.rst b/libcxx/docs/UsingLibcxx.rst --- a/libcxx/docs/UsingLibcxx.rst +++ b/libcxx/docs/UsingLibcxx.rst @@ -254,12 +254,11 @@ replacement scenarios from working, e.g. replacing `operator new` and expecting a non-replaced `operator new[]` to call the replaced `operator new`. -**_LIBCPP_ENABLE_NODISCARD**: - Allow the library to add ``[[nodiscard]]`` attributes to entities not specified - as ``[[nodiscard]]`` by the current language dialect. This includes - backporting applications of ``[[nodiscard]]`` from newer dialects and - additional extended applications at the discretion of the library. All - additional applications of ``[[nodiscard]]`` are disabled by default. +**_LIBCPP_DISABLE_NODISCARD**: + Add ``[[nodiscard]]`` attributes only to entities specified as ``[[nodiscard]]`` + by the current language dialect. This disables backporting applications + of ``[[nodiscard]]`` from newer dialects and additional extended applications + at the discretion of the library. See :ref:`Extended Applications of [[nodiscard]] ` for more information. @@ -356,8 +355,8 @@ liberal application of ``[[nodiscard]]``. For this reason libc++ provides an extension that does just that! The -extension must be enabled by defining ``_LIBCPP_ENABLE_NODISCARD``. The extended -applications of ``[[nodiscard]]`` takes two forms: +extension is enabled by default and can be disabled by defining ``_LIBCPP_ENABLE_NODISCARD``. +The extended applications of ``[[nodiscard]]`` takes two forms: 1. Backporting ``[[nodiscard]]`` to entities declared as such by the standard in newer dialects, but not in the present one. diff --git a/libcxx/include/__config b/libcxx/include/__config --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -880,13 +880,13 @@ // _LIBCPP_NODISCARD_EXT may be used to apply [[nodiscard]] to entities not // specified as such as an extension. -# if defined(_LIBCPP_ENABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT) +# if !defined(_LIBCPP_DISABLE_NODISCARD) && !defined(_LIBCPP_DISABLE_NODISCARD_EXT) # define _LIBCPP_NODISCARD_EXT _LIBCPP_NODISCARD # else # define _LIBCPP_NODISCARD_EXT # endif -# if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && (_LIBCPP_STD_VER > 17 || defined(_LIBCPP_ENABLE_NODISCARD)) +# if !defined(_LIBCPP_DISABLE_NODISCARD_AFTER_CXX17) && (_LIBCPP_STD_VER > 17 || !defined(_LIBCPP_DISABLE_NODISCARD)) # define _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_NODISCARD # else # define _LIBCPP_NODISCARD_AFTER_CXX17