From 4d50879d9c93cdadfd6b0918931907c821d06520 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Wed, 3 Apr 2019 21:17:34 +0000 Subject: [PATCH] Cleanup test failures in no discard tests. llvm-svn: 357637 --- .../diagnostics/nodiscard_extensions.fail.cpp | 10 ++++++++++ .../diagnostics/nodiscard_extensions.pass.cpp | 16 ++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.fail.cpp b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.fail.cpp index 91a63f09e9f2..543fd2456f65 100644 --- a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.fail.cpp +++ b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.fail.cpp @@ -54,11 +54,13 @@ int main(int, char**) { // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} std::binary_search(std::begin(arr), std::end(arr), 1, std::greater()); +#if TEST_STD_VER >= 17 // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} std::clamp(2, 1, 3); // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} std::clamp(2, 1, 3, std::greater()); +#endif // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} std::count_if(std::begin(arr), std::end(arr), P()); @@ -79,12 +81,14 @@ int main(int, char**) { std::equal(std::begin(arr), std::end(arr), std::begin(arr), std::greater()); +#if TEST_STD_VER >= 14 // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} std::equal(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr)); // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} std::equal(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr), std::greater()); +#endif // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} std::find_end(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr)); @@ -142,6 +146,7 @@ int main(int, char**) { std::is_permutation(std::begin(arr), std::end(arr), std::begin(arr), std::greater()); +#if TEST_STD_VER >= 14 // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} std::is_permutation(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr)); @@ -149,6 +154,7 @@ int main(int, char**) { // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} std::is_permutation(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr), std::greater()); +#endif // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} std::is_sorted_until(std::begin(arr), std::end(arr)); @@ -237,12 +243,14 @@ int main(int, char**) { std::mismatch(std::begin(arr), std::end(arr), std::begin(arr), std::greater()); +#if TEST_STD_VER >= 14 // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} std::mismatch(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr)); // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} std::mismatch(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr), std::greater()); +#endif // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} std::none_of(std::begin(arr), std::end(arr), P()); @@ -266,9 +274,11 @@ int main(int, char**) { std::search(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr), std::greater()); +#if TEST_STD_VER >= 17 // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} std::search(std::begin(arr), std::end(arr), std::default_searcher(std::begin(arr), std::end(arr))); +#endif // expected-error-re@+1 {{ignoring return value of function declared with {{'nodiscard'|warn_unused_result}} attribute}} std::unique(std::begin(arr), std::end(arr)); diff --git a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp index efc2bc82dcce..e06ad97d97a3 100644 --- a/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp +++ b/libcxx/test/libcxx/diagnostics/nodiscard_extensions.pass.cpp @@ -37,8 +37,10 @@ int main(int, char**) { std::any_of(std::begin(arr), std::end(arr), P()); std::binary_search(std::begin(arr), std::end(arr), 1); std::binary_search(std::begin(arr), std::end(arr), 1, std::greater()); +#if TEST_STD_VER >= 17 std::clamp(2, 1, 3); std::clamp(2, 1, 3, std::greater()); +#endif std::count_if(std::begin(arr), std::end(arr), P()); std::count(std::begin(arr), std::end(arr), 1); std::equal_range(std::begin(arr), std::end(arr), 1); @@ -46,9 +48,11 @@ int main(int, char**) { std::equal(std::begin(arr), std::end(arr), std::begin(arr)); std::equal(std::begin(arr), std::end(arr), std::begin(arr), std::greater()); +#if TEST_STD_VER >= 14 std::equal(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr)); std::equal(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr), std::greater()); +#endif std::find_end(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr)); std::find_end(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr), std::greater()); @@ -71,10 +75,12 @@ int main(int, char**) { std::is_permutation(std::begin(arr), std::end(arr), std::begin(arr)); std::is_permutation(std::begin(arr), std::end(arr), std::begin(arr), std::greater()); +#if TEST_STD_VER >= 14 std::is_permutation(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr)); std::is_permutation(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr), std::greater()); +#endif std::is_sorted_until(std::begin(arr), std::end(arr)); std::is_sorted_until(std::begin(arr), std::end(arr), std::greater()); std::is_sorted(std::begin(arr), std::end(arr)); @@ -89,26 +95,34 @@ int main(int, char**) { std::max_element(std::begin(arr), std::end(arr), std::greater()); std::max(1, 2); std::max(1, 2, std::greater()); +#if TEST_STD_VER >= 11 std::max({1, 2, 3}); std::max({1, 2, 3}, std::greater()); +#endif std::min_element(std::begin(arr), std::end(arr)); std::min_element(std::begin(arr), std::end(arr), std::greater()); std::min(1, 2); std::min(1, 2, std::greater()); +#if TEST_STD_VER >= 11 std::min({1, 2, 3}); std::min({1, 2, 3}, std::greater()); +#endif std::minmax_element(std::begin(arr), std::end(arr)); std::minmax_element(std::begin(arr), std::end(arr), std::greater()); std::minmax(1, 2); std::minmax(1, 2, std::greater()); +#if TEST_STD_VER >= 11 std::minmax({1, 2, 3}); std::minmax({1, 2, 3}, std::greater()); +#endif std::mismatch(std::begin(arr), std::end(arr), std::begin(arr)); std::mismatch(std::begin(arr), std::end(arr), std::begin(arr), std::greater()); +#if TEST_STD_VER >= 14 std::mismatch(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr)); std::mismatch(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr), std::greater()); +#endif std::none_of(std::begin(arr), std::end(arr), P()); std::remove_if(std::begin(arr), std::end(arr), P()); std::remove(std::begin(arr), std::end(arr), 1); @@ -117,8 +131,10 @@ int main(int, char**) { std::search(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr)); std::search(std::begin(arr), std::end(arr), std::begin(arr), std::end(arr), std::greater()); +#if TEST_STD_VER >= 17 std::search(std::begin(arr), std::end(arr), std::default_searcher(std::begin(arr), std::end(arr))); +#endif std::unique(std::begin(arr), std::end(arr)); std::unique(std::begin(arr), std::end(arr), std::greater()); std::upper_bound(std::begin(arr), std::end(arr), 1);