Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions libcxx/include/__filesystem/copy_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Comment on lines +53 to 63
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a regression test. I wasn't able to find any tests for these functions, so it'd be appreciated if they were added. That would probably have caught this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I'm adding it to libcxx/test/std/input.output/filesystems/fs.enum/enum.copy_options.pass.cpp.


Expand Down
2 changes: 1 addition & 1 deletion libcxx/include/__mdspan/mdspan.h
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int main(int, char**) {
assert(map.required_span_size() == static_cast<signed char>(12));
// 100 x 3 exceeds 256
{
TEST_LIBCPP_ASSERT_FAILURE(([=] { mds.size(); }()), "mdspan: size() is not representable as size_type");
TEST_LIBCPP_ASSERT_FAILURE(([=] { (void)mds.size(); }()), "mdspan: size() is not representable as size_type");
}
}
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// check that <algorithm> functions are marked [[nodiscard]]

// clang-format off
Expand Down Expand Up @@ -188,11 +186,13 @@ void test() {
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::max(1, 2, std::greater<int>());

#if TEST_STD_VER >= 11
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::max({1, 2, 3});

// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::max({1, 2, 3}, std::greater<int>());
#endif

// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::min_element(std::begin(arr), std::end(arr));
Expand All @@ -206,11 +206,13 @@ void test() {
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::min(1, 2, std::greater<int>());

#if TEST_STD_VER >= 11
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::min({1, 2, 3});

// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::min({1, 2, 3}, std::greater<int>());
#endif

// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::minmax_element(std::begin(arr), std::end(arr));
Expand All @@ -224,11 +226,13 @@ void test() {
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::minmax(1, 2, std::greater<int>());

#if TEST_STD_VER >= 11
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::minmax({1, 2, 3});

// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::minmax({1, 2, 3}, std::greater<int>());
#endif

// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::mismatch(std::begin(arr), std::end(arr), std::begin(arr));
Expand Down
6 changes: 2 additions & 4 deletions libcxx/test/libcxx/diagnostics/array.nodiscard.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// check that <array> functions are marked [[nodiscard]]

#include <array>
Expand All @@ -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}}
Expand Down Expand Up @@ -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@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::get<0>(a);
Expand Down
2 changes: 0 additions & 2 deletions libcxx/test/libcxx/diagnostics/cstdlib.nodiscard.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// We don't control the implementation of the stdlib.h functions on windows
// UNSUPPORTED: windows

Expand Down
2 changes: 0 additions & 2 deletions libcxx/test/libcxx/diagnostics/deque.nodiscard.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// check that <deque> functions are marked [[nodiscard]]

#include <deque>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// check that <forward_list> functions are marked [[nodiscard]]

#include <forward_list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// check that <functional> functions are marked [[nodiscard]]

#include <cstddef>
Expand All @@ -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;

Expand Down Expand Up @@ -48,14 +46,16 @@ void test() {
// expected-warning@+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@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::bind([](int a) { return a; }, 94);
// expected-warning@+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}}
Expand Down
2 changes: 0 additions & 2 deletions libcxx/test/libcxx/diagnostics/limits.nodiscard.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// check that <limits> functions are marked [[nodiscard]]

#include <limits>
Expand Down
2 changes: 0 additions & 2 deletions libcxx/test/libcxx/diagnostics/list.nodiscard.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// check that <list> functions are marked [[nodiscard]]

#include <list>
Expand Down
22 changes: 10 additions & 12 deletions libcxx/test/libcxx/diagnostics/mutex.nodiscard.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// UNSUPPORTED: no-threads

// check that <mutex> functions are marked [[nodiscard]]
Expand Down Expand Up @@ -47,23 +45,23 @@ 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
}

// std::lock_guard
{
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
}
}
2 changes: 0 additions & 2 deletions libcxx/test/libcxx/diagnostics/new.nodiscard.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// check that <array> functions are marked [[nodiscard]]

// clang-format off
Expand Down
4 changes: 1 addition & 3 deletions libcxx/test/libcxx/diagnostics/queue.nodiscard.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// check that <queue> functions are marked [[nodiscard]]

#include <queue>

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}}
Expand Down
2 changes: 0 additions & 2 deletions libcxx/test/libcxx/diagnostics/stack.nodiscard.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// check that <stack> functions are marked [[nodiscard]]

#include <stack>
Expand Down
2 changes: 0 additions & 2 deletions libcxx/test/libcxx/diagnostics/string.nodiscard.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// check that <string> functions are marked [[nodiscard]]

#include <string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// check that <string_view> functions are marked [[nodiscard]]

#include <string_view>
Expand Down Expand Up @@ -126,7 +124,7 @@ void test_nonmembers() {

std::hash<std::string_view> hash;
// expected-warning@+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
Expand Down
2 changes: 0 additions & 2 deletions libcxx/test/libcxx/diagnostics/utility.nodiscard.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// check that <utility> functions are marked [[nodiscard]]

#include <utility>
Expand Down
14 changes: 6 additions & 8 deletions libcxx/test/libcxx/diagnostics/vector.nodiscard.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03

// check that <vector> functions are marked [[nodiscard]]

#include <type_traits>
Expand Down Expand Up @@ -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> >();
}
7 changes: 4 additions & 3 deletions libcxx/test/libcxx/thread/nodiscard.verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03
// UNSUPPORTED: no-threads

// Check that functions are marked [[nodiscard]]
Expand Down Expand Up @@ -65,7 +64,7 @@ void test() {
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
m.try_lock();
// expected-warning@+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@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
m.try_lock_until(timePoint);
}
Expand All @@ -75,7 +74,7 @@ void test() {
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
m.try_lock();
// expected-warning@+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@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
m.try_lock_until(timePoint);
}
Expand All @@ -86,8 +85,10 @@ void test() {

// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::try_lock(m1, m2);
#if TEST_STD_VER >= 11
// expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
std::try_lock(m1, m2, m3);
#endif
}

// Condition variables
Expand Down
Loading
Loading