[libcxx-commits] [libcxx] [libc++] Mini-cleanup for `[[nodiscard]]` (PR #172275)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 15 03:37:05 PST 2025


https://github.com/frederick-vs-ja updated https://github.com/llvm/llvm-project/pull/172275

>From 10f3930db60caaaf9c10e047a71444a87bd17e07 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 15 Dec 2025 18:21:20 +0800
Subject: [PATCH 1/3] Remove incorrect `[[nodiscard]]` from compound assignment
 operators

Also add regression tests.
---
 libcxx/include/__filesystem/copy_options.h               | 6 +++---
 .../filesystems/fs.enum/enum.copy_options.pass.cpp       | 9 +++++++++
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/libcxx/include/__filesystem/copy_options.h b/libcxx/include/__filesystem/copy_options.h
index cba719dbed1f6..d9039a6492fc2 100644
--- a/libcxx/include/__filesystem/copy_options.h
+++ b/libcxx/include/__filesystem/copy_options.h
@@ -50,15 +50,15 @@ enum class copy_options : unsigned short {
   return static_cast<copy_options>(~static_cast<unsigned short>(__lhs));
 }
 
-[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline copy_options& operator&=(copy_options& __lhs, copy_options __rhs) {
+_LIBCPP_HIDE_FROM_ABI inline copy_options& operator&=(copy_options& __lhs, copy_options __rhs) {
   return __lhs = __lhs & __rhs;
 }
 
-[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline copy_options& operator|=(copy_options& __lhs, copy_options __rhs) {
+_LIBCPP_HIDE_FROM_ABI inline copy_options& operator|=(copy_options& __lhs, copy_options __rhs) {
   return __lhs = __lhs | __rhs;
 }
 
-[[nodiscard]] _LIBCPP_HIDE_FROM_ABI inline copy_options& operator^=(copy_options& __lhs, copy_options __rhs) {
+_LIBCPP_HIDE_FROM_ABI inline copy_options& operator^=(copy_options& __lhs, copy_options __rhs) {
   return __lhs = __lhs ^ __rhs;
 }
 
diff --git a/libcxx/test/std/input.output/filesystems/fs.enum/enum.copy_options.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.enum/enum.copy_options.pass.cpp
index 4ef28ee01d8d0..d61a9e32f4e9b 100644
--- a/libcxx/test/std/input.output/filesystems/fs.enum/enum.copy_options.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.enum/enum.copy_options.pass.cpp
@@ -61,5 +61,14 @@ int main(int, char**) {
           E::create_hard_links   == ME(256),
         "Expected enumeration values do not match");
 
+  // Verify that compound assignment operators are not incorrectly marked [[nodiscard]],
+  // to avoid regression in https://llvm.org/PR171085.
+  {
+    E e = E::none;
+    e &= E::skip_existing;
+    e |= E::recursive;
+    e ^= E::create_hard_links;
+  }
+
   return 0;
 }

>From 3f4c34ad3926878f17e1282163e2a23577610ba3 Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 15 Dec 2025 18:21:54 +0800
Subject: [PATCH 2/3] Add missing `[[nodiscard]]` to `mdspan::size`

---
 libcxx/include/__mdspan/mdspan.h                                | 2 +-
 libcxx/test/libcxx/containers/views/mdspan/nodiscard.verify.cpp | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libcxx/include/__mdspan/mdspan.h b/libcxx/include/__mdspan/mdspan.h
index 9f3139a874ff9..9d3d35cd558a1 100644
--- a/libcxx/include/__mdspan/mdspan.h
+++ b/libcxx/include/__mdspan/mdspan.h
@@ -214,7 +214,7 @@ class mdspan {
     }(make_index_sequence<rank()>()));
   }
 
-  _LIBCPP_HIDE_FROM_ABI constexpr size_type size() const noexcept {
+  [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr size_type size() const noexcept {
     // Could leave this as only checked in debug mode: semantically size() is never
     // guaranteed to be related to any accessible range
     _LIBCPP_ASSERT_UNCATEGORIZED(
diff --git a/libcxx/test/libcxx/containers/views/mdspan/nodiscard.verify.cpp b/libcxx/test/libcxx/containers/views/mdspan/nodiscard.verify.cpp
index 71f53f8f1f737..d248656ec0ae5 100644
--- a/libcxx/test/libcxx/containers/views/mdspan/nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/containers/views/mdspan/nodiscard.verify.cpp
@@ -33,6 +33,8 @@ void test() {
   mdsp.static_extent(0); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
   mdsp.extent(0);        // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
 
+  mdsp.size(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
   mdsp.extents();     // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
   mdsp.data_handle(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
   mdsp.mapping();     // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}

>From 95fcf722850ccf0f2a9475388c0fcf7ca7aa3ede Mon Sep 17 00:00:00 2001
From: "A. Jiang" <de34 at live.cn>
Date: Mon, 15 Dec 2025 18:30:50 +0800
Subject: [PATCH 3/3] Enable verifying `[[nodiscard]]` in C++03 for various
 components

libc++ backports many things from C++11 to C++03, so it would be
suitable to verify `[[nodiscard]]` in C++03 mode for them.

Some test files are skipped because they're being touch by other
patches.
---
 .../algorithm.nodiscard.verify.cpp            |  8 +++++--
 .../diagnostics/array.nodiscard.verify.cpp    |  6 ++---
 .../diagnostics/cstdlib.nodiscard.verify.cpp  |  2 --
 .../diagnostics/deque.nodiscard.verify.cpp    |  2 --
 .../forward_list.nodiscard.verify.cpp         |  2 --
 .../functional.nodiscard.verify.cpp           |  8 +++----
 .../diagnostics/limits.nodiscard.verify.cpp   |  2 --
 .../diagnostics/list.nodiscard.verify.cpp     |  2 --
 .../diagnostics/mutex.nodiscard.verify.cpp    | 22 +++++++++----------
 .../diagnostics/new.nodiscard.verify.cpp      |  2 --
 .../diagnostics/queue.nodiscard.verify.cpp    |  4 +---
 .../diagnostics/stack.nodiscard.verify.cpp    |  2 --
 .../diagnostics/string.nodiscard.verify.cpp   |  2 --
 .../string_view.nodiscard.verify.cpp          |  4 +---
 .../diagnostics/utility.nodiscard.verify.cpp  |  2 --
 .../diagnostics/vector.nodiscard.verify.cpp   | 14 +++++-------
 .../test/libcxx/thread/nodiscard.verify.cpp   |  7 +++---
 .../utilities/smartptr/nodiscard.verify.cpp   |  6 ++---
 18 files changed, 36 insertions(+), 61 deletions(-)

diff --git a/libcxx/test/libcxx/diagnostics/algorithm.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/algorithm.nodiscard.verify.cpp
index 14febc12a8a2d..d4743f4c404c9 100644
--- a/libcxx/test/libcxx/diagnostics/algorithm.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/algorithm.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // check that <algorithm> functions are marked [[nodiscard]]
 
 // clang-format off
@@ -188,11 +186,13 @@ void test() {
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::max(1, 2, std::greater<int>());
 
+#if TEST_STD_VER >= 11
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::max({1, 2, 3});
 
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::max({1, 2, 3}, std::greater<int>());
+#endif
 
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::min_element(std::begin(arr), std::end(arr));
@@ -206,11 +206,13 @@ void test() {
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::min(1, 2, std::greater<int>());
 
+#if TEST_STD_VER >= 11
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::min({1, 2, 3});
 
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::min({1, 2, 3}, std::greater<int>());
+#endif
 
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::minmax_element(std::begin(arr), std::end(arr));
@@ -224,11 +226,13 @@ void test() {
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::minmax(1, 2, std::greater<int>());
 
+#if TEST_STD_VER >= 11
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::minmax({1, 2, 3});
 
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::minmax({1, 2, 3}, std::greater<int>());
+#endif
 
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::mismatch(std::begin(arr), std::end(arr), std::begin(arr));
diff --git a/libcxx/test/libcxx/diagnostics/array.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/array.nodiscard.verify.cpp
index 8e49807732de7..e51109dcc4e5d 100644
--- a/libcxx/test/libcxx/diagnostics/array.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/array.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // check that <array> functions are marked [[nodiscard]]
 
 #include <array>
@@ -18,7 +16,7 @@
 template <std::size_t N>
 void test_members() {
   std::array<int, N> a;
-  const std::array<int, N> ca{};
+  const std::array<int, N> ca = {};
 
   a.begin();    // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
   ca.begin();   // expected-warning 2 {{ignoring return value of function declared with 'nodiscard' attribute}}
@@ -57,7 +55,7 @@ void test_members() {
 
 template <typename ArrT>
 void test_get() {
-  std::array<int, 94> a{};
+  std::array<int, 94> a = {};
 
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::get<0>(a);
diff --git a/libcxx/test/libcxx/diagnostics/cstdlib.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/cstdlib.nodiscard.verify.cpp
index d3c809f22816b..52e897662fef6 100644
--- a/libcxx/test/libcxx/diagnostics/cstdlib.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/cstdlib.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // We don't control the implementation of the stdlib.h functions on windows
 // UNSUPPORTED: windows
 
diff --git a/libcxx/test/libcxx/diagnostics/deque.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/deque.nodiscard.verify.cpp
index a9adb1757b8ef..c10a99afee8fa 100644
--- a/libcxx/test/libcxx/diagnostics/deque.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/deque.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // check that <deque> functions are marked [[nodiscard]]
 
 #include <deque>
diff --git a/libcxx/test/libcxx/diagnostics/forward_list.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/forward_list.nodiscard.verify.cpp
index 671c7f71ab2a2..596dc52cdd7aa 100644
--- a/libcxx/test/libcxx/diagnostics/forward_list.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/forward_list.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // check that <forward_list> functions are marked [[nodiscard]]
 
 #include <forward_list>
diff --git a/libcxx/test/libcxx/diagnostics/functional.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/functional.nodiscard.verify.cpp
index 521870f2484a2..a8337c5e36c72 100644
--- a/libcxx/test/libcxx/diagnostics/functional.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/functional.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // check that <functional> functions are marked [[nodiscard]]
 
 #include <cstddef>
@@ -20,7 +18,7 @@ void test() {
 
   // Function wrappers
 
-#if !defined(TEST_HAS_NO_RTTI)
+#if TEST_STD_VER >= 11 && !defined(TEST_HAS_NO_RTTI)
   std::function<void(int)> f;
   const std::function<void(int)> cf;
 
@@ -48,14 +46,16 @@ void test() {
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::bind_front([](int a) { return a; }, 94);
 #endif
+#if TEST_STD_VER >= 11
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::bind([](int a) { return a; }, 94);
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
   std::bind<float>([](int a) { return a; }, 94);
+#endif
 
   // Reference wrappers
 
-  std::reference_wrapper<int> rw{i};
+  std::reference_wrapper<int> rw = i;
   rw.get(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
 
   std::ref(i);  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
diff --git a/libcxx/test/libcxx/diagnostics/limits.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/limits.nodiscard.verify.cpp
index 7a81b84378c52..d3bea9ea031f4 100644
--- a/libcxx/test/libcxx/diagnostics/limits.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/limits.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // check that <limits> functions are marked [[nodiscard]]
 
 #include <limits>
diff --git a/libcxx/test/libcxx/diagnostics/list.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/list.nodiscard.verify.cpp
index bfce9b85ef76c..cff607e738d35 100644
--- a/libcxx/test/libcxx/diagnostics/list.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/list.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // check that <list> functions are marked [[nodiscard]]
 
 #include <list>
diff --git a/libcxx/test/libcxx/diagnostics/mutex.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/mutex.nodiscard.verify.cpp
index b9890ced55bb1..c82a7edadcd06 100644
--- a/libcxx/test/libcxx/diagnostics/mutex.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/mutex.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // UNSUPPORTED: no-threads
 
 // check that <mutex> functions are marked [[nodiscard]]
@@ -47,14 +45,14 @@ void test() {
     std::unique_lock<M> other;
 
     // clang-format off
-    std::unique_lock<M>{};                      // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
-    std::unique_lock<M>{m};                     // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
-    std::unique_lock<M>{m, std::defer_lock};    // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
-    std::unique_lock<M>{m, std::try_to_lock};   // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
-    std::unique_lock<M>{m, std::adopt_lock};    // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
-    std::unique_lock<M>{m, time_point};         // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
-    std::unique_lock<M>{m, duration};           // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
-    std::unique_lock<M>(std::move(other));      // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
+    std::unique_lock<M>();                        // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
+    (std::unique_lock<M>)(m);                     // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
+    std::unique_lock<M>(m, std::defer_lock_t());  // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
+    std::unique_lock<M>(m, std::try_to_lock_t()); // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
+    std::unique_lock<M>(m, std::adopt_lock_t());  // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
+    std::unique_lock<M>(m, time_point);           // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
+    std::unique_lock<M>(m, duration);             // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
+    std::unique_lock<M>(std::move(other));        // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
     // clang-format on
   }
 
@@ -62,8 +60,8 @@ void test() {
   {
     std::mutex m;
     // clang-format off
-    std::lock_guard<std::mutex>{m};                  // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
-    std::lock_guard<std::mutex>{m, std::adopt_lock}; // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
+    (std::lock_guard<std::mutex>)(m);                    // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
+    std::lock_guard<std::mutex>(m, std::adopt_lock_t()); // expected-warning {{ignoring temporary created by a constructor declared with 'nodiscard' attribute}}
     // clang-format on
   }
 }
diff --git a/libcxx/test/libcxx/diagnostics/new.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/new.nodiscard.verify.cpp
index 505618c0b88d7..b2af8d4a74027 100644
--- a/libcxx/test/libcxx/diagnostics/new.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/new.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // check that <array> functions are marked [[nodiscard]]
 
 // clang-format off
diff --git a/libcxx/test/libcxx/diagnostics/queue.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/queue.nodiscard.verify.cpp
index da1f9ff3f01f6..d23934cc15053 100644
--- a/libcxx/test/libcxx/diagnostics/queue.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/queue.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // check that <queue> functions are marked [[nodiscard]]
 
 #include <queue>
@@ -15,7 +13,7 @@
 void test() {
   {
     std::queue<int> q;
-    const std::queue<int> cq{};
+    const std::queue<int> cq;
 
     q.empty();  // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
     q.size();   // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
diff --git a/libcxx/test/libcxx/diagnostics/stack.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/stack.nodiscard.verify.cpp
index a0a5b3c898a8c..d176fd4cf6f68 100644
--- a/libcxx/test/libcxx/diagnostics/stack.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/stack.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // check that <stack> functions are marked [[nodiscard]]
 
 #include <stack>
diff --git a/libcxx/test/libcxx/diagnostics/string.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/string.nodiscard.verify.cpp
index 0ff92cac3a3b2..3a941598e6e68 100644
--- a/libcxx/test/libcxx/diagnostics/string.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/string.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // check that <string> functions are marked [[nodiscard]]
 
 #include <string>
diff --git a/libcxx/test/libcxx/diagnostics/string_view.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/string_view.nodiscard.verify.cpp
index 89e4a5b44ab48..7c282f205e310 100644
--- a/libcxx/test/libcxx/diagnostics/string_view.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/string_view.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // check that <string_view> functions are marked [[nodiscard]]
 
 #include <string_view>
@@ -126,7 +124,7 @@ void test_nonmembers() {
 
   std::hash<std::string_view> hash;
   // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
-  hash(std::string_view{});
+  hash(std::string_view());
 
 #if TEST_STD_VER >= 14
   // string_view literals
diff --git a/libcxx/test/libcxx/diagnostics/utility.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/utility.nodiscard.verify.cpp
index 2f5b3ba0fc642..3d6ff423dc917 100644
--- a/libcxx/test/libcxx/diagnostics/utility.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/utility.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // check that <utility> functions are marked [[nodiscard]]
 
 #include <utility>
diff --git a/libcxx/test/libcxx/diagnostics/vector.nodiscard.verify.cpp b/libcxx/test/libcxx/diagnostics/vector.nodiscard.verify.cpp
index a5cad1a1627e6..161a3c7601328 100644
--- a/libcxx/test/libcxx/diagnostics/vector.nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/diagnostics/vector.nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // check that <vector> functions are marked [[nodiscard]]
 
 #include <type_traits>
@@ -44,11 +42,11 @@ void test_non_vector_bool() {
 }
 
 void instantiate() {
-  test<std::vector<int>>();
-  test<const std::vector<int>>();
-  test<std::vector<bool>>();
-  test<const std::vector<bool>>();
+  test<std::vector<int> >();
+  test<const std::vector<int> >();
+  test<std::vector<bool> >();
+  test<const std::vector<bool> >();
 
-  test_non_vector_bool<std::vector<int>>();
-  test_non_vector_bool<const std::vector<int>>();
+  test_non_vector_bool<std::vector<int> >();
+  test_non_vector_bool<const std::vector<int> >();
 }
diff --git a/libcxx/test/libcxx/thread/nodiscard.verify.cpp b/libcxx/test/libcxx/thread/nodiscard.verify.cpp
index 19e43f88db700..73e4f932b6369 100644
--- a/libcxx/test/libcxx/thread/nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/thread/nodiscard.verify.cpp
@@ -6,7 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
 // UNSUPPORTED: no-threads
 
 // Check that functions are marked [[nodiscard]]
@@ -65,7 +64,7 @@ void test() {
     // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
     m.try_lock();
     // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
-    m.try_lock_for(std::chrono::nanoseconds{82});
+    m.try_lock_for(std::chrono::nanoseconds(82));
     // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
     m.try_lock_until(timePoint);
   }
@@ -75,7 +74,7 @@ void test() {
     // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
     m.try_lock();
     // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
-    m.try_lock_for(std::chrono::nanoseconds{82});
+    m.try_lock_for(std::chrono::nanoseconds(82));
     // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
     m.try_lock_until(timePoint);
   }
@@ -86,8 +85,10 @@ void test() {
 
     // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
     std::try_lock(m1, m2);
+#if TEST_STD_VER >= 11
     // expected-warning at +1 {{ignoring return value of function declared with 'nodiscard' attribute}}
     std::try_lock(m1, m2, m3);
+#endif
   }
 
   // Condition variables
diff --git a/libcxx/test/libcxx/utilities/smartptr/nodiscard.verify.cpp b/libcxx/test/libcxx/utilities/smartptr/nodiscard.verify.cpp
index 6e713fe5217ba..6943a4002c245 100644
--- a/libcxx/test/libcxx/utilities/smartptr/nodiscard.verify.cpp
+++ b/libcxx/test/libcxx/utilities/smartptr/nodiscard.verify.cpp
@@ -6,8 +6,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-// UNSUPPORTED: c++03
-
 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_SHARED_PTR_UNIQUE -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
 
 // <memory>
@@ -42,7 +40,7 @@ void test() {
     std::make_unique_for_overwrite<int[]>(5);
 #endif
 
-    std::hash<std::unique_ptr<int>> hash;
+    std::hash<std::unique_ptr<int> > hash;
     hash(uPtr); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
   }
   { // [util.smartptr.weak.bad]
@@ -127,7 +125,7 @@ void test() {
     std::get_deleter<int[]>(sPtr);
 #endif
 
-    std::hash<std::shared_ptr<int[]>> hash;
+    std::hash<std::shared_ptr<int[]> > hash;
     hash(sPtr); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
   }
   { // [util.smartptr.weak]



More information about the libcxx-commits mailing list