diff --git a/libc/config/gpu/nvptx/config.json b/libc/config/gpu/nvptx/config.json index 30ae10e2cfd61..a262d6249ab6e 100644 --- a/libc/config/gpu/nvptx/config.json +++ b/libc/config/gpu/nvptx/config.json @@ -6,35 +6,44 @@ }, "printf": { "LIBC_CONF_PRINTF_DISABLE_FLOAT": { - "value": true + "value": true, + "define": "LIBC_COPT_PRINTF_DISABLE_FLOAT" }, "LIBC_CONF_PRINTF_DISABLE_INDEX_MODE": { - "value": true + "value": true, + "define": "LIBC_COPT_PRINTF_DISABLE_INDEX_MODE" }, "LIBC_CONF_PRINTF_DISABLE_WRITE_INT": { - "value": true + "value": true, + "copt": "LIBC_COPT_PRINTF_DISABLE_WRITE_INT" }, "LIBC_CONF_PRINTF_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE": { - "value": false + "value": false, + "copt": "LIBC_COPT_FLOAT_TO_STR_USE_MEGA_LONG_DOUBLE_TABLE" }, "LIBC_CONF_PRINTF_DISABLE_STRERROR": { - "value": true + "value": true, + "copt": "LIBC_COPT_PRINTF_DISABLE_STRERROR" }, "LIBC_CONF_PRINTF_RUNTIME_DISPATCH": { - "value": false + "value": false, + "copt": "LIBC_COPT_PRINTF_RUNTIME_DISPATCH" } }, "scanf": { "LIBC_CONF_SCANF_DISABLE_FLOAT": { - "value": true + "value": true, + "copt": "LIBC_COPT_SCANF_DISABLE_FLOAT" }, "LIBC_CONF_SCANF_DISABLE_INDEX_MODE": { - "value": true + "value": true, + "copt": "LIBC_COPT_SCANF_DISABLE_INDEX_MODE" } }, "math": { "LIBC_CONF_MATH_OPTIMIZATIONS": { - "value": "(LIBC_MATH_SKIP_ACCURATE_PASS | LIBC_MATH_SMALL_TABLES | LIBC_MATH_NO_ERRNO | LIBC_MATH_NO_EXCEPT)" + "value": "(LIBC_COPT_MATH_SKIP_ACCURATE_PASS | LIBC_COPT_MATH_SMALL_TABLES)", + "define": "LIBC_COPT_MATH_OPTIMIZATIONS" } } } diff --git a/libcxx/include/__expected/expected.h b/libcxx/include/__expected/expected.h index 03bbd1623ed5c..a1179038d69c2 100644 --- a/libcxx/include/__expected/expected.h +++ b/libcxx/include/__expected/expected.h @@ -60,7 +60,7 @@ _LIBCPP_PUSH_MACROS _LIBCPP_BEGIN_NAMESPACE_STD template -class expected; +class [[nodiscard]] expected; template struct __is_std_expected : false_type {}; @@ -1354,7 +1354,7 @@ class __expected_void_base { template requires is_void_v<_Tp> -class expected<_Tp, _Err> : private __expected_void_base<_Err> { +class [[nodiscard]] expected<_Tp, _Err> : private __expected_void_base<_Err> { static_assert(__valid_std_unexpected<_Err>::value, "[expected.void.general] A program that instantiates expected with a E that is not a " "valid argument for unexpected is ill-formed"); diff --git a/libcxx/test/libcxx/utilities/expected/expected.expected/and_then.mandates.verify.cpp b/libcxx/test/libcxx/utilities/expected/expected.expected/and_then.mandates.verify.cpp index c46ab633295c1..a0c3ac203b6e7 100644 --- a/libcxx/test/libcxx/utilities/expected/expected.expected/and_then.mandates.verify.cpp +++ b/libcxx/test/libcxx/utilities/expected/expected.expected/and_then.mandates.verify.cpp @@ -30,6 +30,7 @@ // U is a specialization of std::expected and std::is_same_v is true #include +#include #include struct NotSameAsInt {}; @@ -51,7 +52,7 @@ void test() { // U is not a specialization of std::expected { std::expected f1(1); - f1.and_then(lval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} + std::ignore = f1.and_then(lval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(value()) must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} @@ -60,7 +61,7 @@ void test() { // !std::is_same_v { std::expected f1(1); - f1.and_then(lval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)(int &)>' requested here}} + std::ignore = f1.and_then(lval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)(int &)>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(value()) must have the same error_type as this expected}} } } @@ -70,7 +71,7 @@ void test() { // U is not a specialization of std::expected { const std::expected f1(1); - f1.and_then(clval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} + std::ignore = f1.and_then(clval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(value()) must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} @@ -79,7 +80,7 @@ void test() { // !std::is_same_v { const std::expected f1(1); - f1.and_then(clval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)(const int &)>' requested here}} + std::ignore = f1.and_then(clval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)(const int &)>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(value()) must have the same error_type as this expected}} } @@ -90,7 +91,7 @@ void test() { // U is not a specialization of std::expected { std::expected f1(1); - std::move(f1).and_then(rval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} + std::ignore = std::move(f1).and_then(rval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(std::move(value())) must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} @@ -99,7 +100,7 @@ void test() { // !std::is_same_v { std::expected f1(1); - std::move(f1).and_then(rval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)(int &&)>' requested here}} + std::ignore = std::move(f1).and_then(rval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)(int &&)>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(std::move(value())) must have the same error_type as this expected}} } } @@ -109,7 +110,7 @@ void test() { // U is not a specialization of std::expected { const std::expected f1(1); - std::move(f1).and_then(crval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} + std::ignore = std::move(f1).and_then(crval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(std::move(value())) must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} @@ -118,9 +119,16 @@ void test() { // !std::is_same_v { const std::expected f1(1); - std::move(f1).and_then(crval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)(const int &&)>' requested here}} + std::ignore = std::move(f1).and_then(crval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)(const int &&)>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(std::move(value())) must have the same error_type as this expected}} } } + + // Test nodiscard + { + std::expected f1(1); + + f1.and_then([](const int&){ return std::expected(1); }); // expected-warning{{ignoring return value of function declared with 'nodiscard' attribute}} + } } // clang-format on diff --git a/libcxx/test/libcxx/utilities/expected/expected.expected/nodiscard.verify.cpp b/libcxx/test/libcxx/utilities/expected/expected.expected/nodiscard.verify.cpp new file mode 100644 index 0000000000000..d9a031c6c738a --- /dev/null +++ b/libcxx/test/libcxx/utilities/expected/expected.expected/nodiscard.verify.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// REQUIRES: std-at-least-c++23 + +// + +// Test that ignoring std::expected generates [[nodiscard]] warnings. + +#include + +std::expected returns_expected() { return std::expected(5); } + +std::expected returns_expected_void() { return std::expected(); } + +void test() { + returns_expected(); // expected-warning{{ignoring return value of function declared with 'nodiscard' attribute}} + + returns_expected_void(); // expected-warning{{ignoring return value of function declared with 'nodiscard' attribute}} +} diff --git a/libcxx/test/libcxx/utilities/expected/expected.expected/or_else.mandates.verify.cpp b/libcxx/test/libcxx/utilities/expected/expected.expected/or_else.mandates.verify.cpp index af1fa53307960..64aac319fc50b 100644 --- a/libcxx/test/libcxx/utilities/expected/expected.expected/or_else.mandates.verify.cpp +++ b/libcxx/test/libcxx/utilities/expected/expected.expected/or_else.mandates.verify.cpp @@ -30,6 +30,7 @@ // G is a specialization of std::expected and std::is_same_v is true #include +#include #include struct NotSameAsInt {}; @@ -51,7 +52,7 @@ void test() { // G is not a specialization of std::expected { std::expected f1(std::unexpected(1)); - f1.or_else(lval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} + std::ignore = f1.or_else(lval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(error()) must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} @@ -60,7 +61,7 @@ void test() { // !std::is_same_v { std::expected f1(std::unexpected(1)); - f1.or_else(lval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(int &)>' requested here}} + std::ignore = f1.or_else(lval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(int &)>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(error()) must have the same value_type as this expected}} } } @@ -70,7 +71,7 @@ void test() { // G is not a specialization of std::expected { const std::expected f1(std::unexpected(1)); - f1.or_else(clval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} + std::ignore = f1.or_else(clval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(error()) must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} @@ -79,7 +80,7 @@ void test() { // !std::is_same_v { const std::expected f1(std::unexpected(1)); - f1.or_else(clval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(const int &)>' requested here}} + std::ignore = f1.or_else(clval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(const int &)>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(error()) must have the same value_type as this expected}} } } @@ -89,7 +90,7 @@ void test() { // G is not a specialization of std::expected { std::expected f1(std::unexpected(1)); - std::move(f1).or_else(rval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} + std::ignore = std::move(f1).or_else(rval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(std::move(error())) must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} @@ -98,7 +99,7 @@ void test() { // !std::is_same_v { std::expected f1(std::unexpected(1)); - std::move(f1).or_else(rval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(int &&)>' requested here}} + std::ignore = std::move(f1).or_else(rval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(int &&)>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(std::move(error())) must have the same value_type as this expected}} } } @@ -108,7 +109,7 @@ void test() { // G is not a specialization of std::expected { const std::expected f1(std::unexpected(1)); - std::move(f1).or_else(crval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} + std::ignore = std::move(f1).or_else(crval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(std::move(error())) must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} @@ -117,9 +118,17 @@ void test() { // !std::is_same_v { const std::expected f1(std::unexpected(1)); - std::move(f1).or_else(crval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(const int &&)>' requested here}} + std::ignore = std::move(f1).or_else(crval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(const int &&)>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(std::move(error())) must have the same value_type as this expected}} } } + + // Test nodiscard + { + std::expected f1(1); + + f1.or_else([](const int&){ return std::expected(1); }); // expected-warning{{ignoring return value of function declared with 'nodiscard' attribute}} + + } } // clang-format on diff --git a/libcxx/test/libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp b/libcxx/test/libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp index 61374094b7adf..0cde41b7ca95f 100644 --- a/libcxx/test/libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp +++ b/libcxx/test/libcxx/utilities/expected/expected.expected/transform_error.mandates.verify.cpp @@ -38,6 +38,7 @@ // G g(invoke(std::forward(f), std::move(error()))); is well-formed. #include +#include #include static int val; @@ -58,12 +59,12 @@ void test() { // Test & overload { std::expected e; - e.transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = e.transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} // expected-error-re@*:* {{static assertion failed {{.*}}[expected.object.general] A program that instantiates the definition of template expected for {{.*}} is ill-formed.}} // expected-error-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}}} - e.transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = e.transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} // expected-error-re@*:* {{static assertion failed {{.*}}[expected.object.general] A program that instantiates the definition of template expected for {{.*}} is ill-formed.}} // expected-warning-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}, which is a Microsoft extension}} @@ -72,27 +73,27 @@ void test() { // Test const& overload { const std::expected e; - e.transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = e.transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-2 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} - e.transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = e.transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-2 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} } // Test && overload { std::expected e; - std::move(e).transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = std::move(e).transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-2 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} - std::move(e).transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = std::move(e).transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-2 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} } // Test const&& overload { const std::expected e; - std::move(e).transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = std::move(e).transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-2 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} - std::move(e).transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = std::move(e).transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-2 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} } } diff --git a/libcxx/test/libcxx/utilities/expected/expected.void/and_then.mandates.verify.cpp b/libcxx/test/libcxx/utilities/expected/expected.void/and_then.mandates.verify.cpp index e1a7ec5ff4d72..8a59593c60c5e 100644 --- a/libcxx/test/libcxx/utilities/expected/expected.void/and_then.mandates.verify.cpp +++ b/libcxx/test/libcxx/utilities/expected/expected.void/and_then.mandates.verify.cpp @@ -30,6 +30,7 @@ // U is a specialization of std::expected and std::is_same_v is true #include +#include #include struct NotSameAsInt {}; @@ -51,7 +52,7 @@ void test() { // U is not a specialization of std::expected { std::expected f1; - f1.and_then(lval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} + std::ignore = f1.and_then(lval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f() must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} @@ -60,7 +61,7 @@ void test() { // !std::is_same_v { std::expected f1; - f1.and_then(lval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)()>' requested here}} + std::ignore = f1.and_then(lval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)()>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f() must have the same error_type as this expected}} } } @@ -70,7 +71,7 @@ void test() { // U is not a specialization of std::expected { const std::expected f1; - f1.and_then(clval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} + std::ignore = f1.and_then(clval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f() must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} @@ -79,7 +80,7 @@ void test() { // !std::is_same_v { const std::expected f1; - f1.and_then(clval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)()>' requested here}} + std::ignore = f1.and_then(clval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)()>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f() must have the same error_type as this expected}} } } @@ -89,7 +90,7 @@ void test() { // U is not a specialization of std::expected { std::expected f1; - std::move(f1).and_then(rval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} + std::ignore = std::move(f1).and_then(rval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f() must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} @@ -98,7 +99,7 @@ void test() { // !std::is_same_v { std::expected f1; - std::move(f1).and_then(rval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)()>' requested here}} + std::ignore = std::move(f1).and_then(rval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)()>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f() must have the same error_type as this expected}} } } @@ -108,7 +109,7 @@ void test() { // U is not a specialization of std::expected { const std::expected f1; - std::move(f1).and_then(crval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} + std::ignore = std::move(f1).and_then(crval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::and_then' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f() must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} // expected-error-re@*:* {{no matching constructor for initialization of{{.*}}}} @@ -117,7 +118,7 @@ void test() { // !std::is_same_v { const std::expected f1; - std::move(f1).and_then(crval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)()>' requested here}} + std::ignore = std::move(f1).and_then(crval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::and_then (&)()>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f() must have the same error_type as this expected}} } } diff --git a/libcxx/test/libcxx/utilities/expected/expected.void/or_else.mandates.verify.cpp b/libcxx/test/libcxx/utilities/expected/expected.void/or_else.mandates.verify.cpp index 3046d09d6af55..b182faf99598c 100644 --- a/libcxx/test/libcxx/utilities/expected/expected.void/or_else.mandates.verify.cpp +++ b/libcxx/test/libcxx/utilities/expected/expected.void/or_else.mandates.verify.cpp @@ -30,6 +30,7 @@ // G is a specialization of std::expected and std::is_same_v is true #include +#include #include struct NotSameAsInt {}; @@ -51,7 +52,7 @@ void test() { // G is not a specialization of std::expected { std::expected f1(std::unexpected(1)); - f1.or_else(lval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} + std::ignore = f1.or_else(lval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(error()) must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} } @@ -59,7 +60,7 @@ void test() { // !std::is_same_v { std::expected f1(std::unexpected(1)); - f1.or_else(lval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(int &)>' requested here}} + std::ignore = f1.or_else(lval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(int &)>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(error()) must have the same value_type as this expected}} } } @@ -69,7 +70,7 @@ void test() { // G is not a specialization of std::expected { const std::expected f1(std::unexpected(1)); - f1.or_else(clval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} + std::ignore = f1.or_else(clval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(error()) must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} } @@ -77,7 +78,7 @@ void test() { // !std::is_same_v { const std::expected f1(std::unexpected(1)); - f1.or_else(clval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(const int &)>' requested here}} + std::ignore = f1.or_else(clval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(const int &)>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(error()) must have the same value_type as this expected}} } } @@ -87,7 +88,7 @@ void test() { // G is not a specialization of std::expected { std::expected f1(std::unexpected(1)); - std::move(f1).or_else(rval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} + std::ignore = std::move(f1).or_else(rval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(std::move(error())) must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} } @@ -95,7 +96,7 @@ void test() { // !std::is_same_v { std::expected f1(std::unexpected(1)); - std::move(f1).or_else(rval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(int &&)>' requested here}} + std::ignore = std::move(f1).or_else(rval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(int &&)>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(std::move(error())) must have the same value_type as this expected}} } } @@ -105,7 +106,7 @@ void test() { // G is not a specialization of std::expected { const std::expected f1(std::unexpected(1)); - std::move(f1).or_else(crval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} + std::ignore = std::move(f1).or_else(crval_return_not_std_expected); // expected-note{{in instantiation of function template specialization 'std::expected::or_else' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(std::move(error())) must be a specialization of std::expected}} // expected-error-re@*:* {{{{.*}}cannot be used prior to '::' because it has no members}} } @@ -113,7 +114,7 @@ void test() { // !std::is_same_v { const std::expected f1(std::unexpected(1)); - std::move(f1).or_else(crval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(const int &&)>' requested here}} + std::ignore = std::move(f1).or_else(crval_error_type_not_same_as_int); // expected-note{{in instantiation of function template specialization 'std::expected::or_else (&)(const int &&)>' requested here}} // expected-error-re@*:* {{static assertion failed {{.*}}The result of f(std::move(error())) must have the same value_type as this expected}} } } diff --git a/libcxx/test/libcxx/utilities/expected/expected.void/transform_error.mandates.verify.cpp b/libcxx/test/libcxx/utilities/expected/expected.void/transform_error.mandates.verify.cpp index 16233cd90d219..332d75ec8d4c8 100644 --- a/libcxx/test/libcxx/utilities/expected/expected.void/transform_error.mandates.verify.cpp +++ b/libcxx/test/libcxx/utilities/expected/expected.void/transform_error.mandates.verify.cpp @@ -39,6 +39,7 @@ // G g(invoke(std::forward(f), std::move(error()))); is well-formed. #include +#include #include static int val; @@ -59,13 +60,13 @@ void test() { // Test & overload { std::expected e; - e.transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = e.transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} // expected-error-re@*:* {{static assertion failed {{.*}}A program that instantiates expected with a E that is not a valid argument for unexpected is ill-formed}} // expected-error-re@*:* 0-1 {{call to deleted constructor of {{.*}}}} // expected-error-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}}} - e.transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = e.transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} // expected-error-re@*:* {{static assertion failed {{.*}}A program that instantiates expected with a E that is not a valid argument for unexpected is ill-formed}} // expected-warning-re@*:* 0-1 {{union member {{.*}} has reference type {{.*}}, which is a Microsoft extension}} @@ -74,9 +75,9 @@ void test() { // Test const& overload { const std::expected e; - e.transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = e.transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} - e.transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = e.transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} // expected-error-re@*:* 0-1 {{call to deleted constructor of {{.*}}}} } @@ -84,18 +85,18 @@ void test() { // Test && overload { std::expected e; - std::move(e).transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = std::move(e).transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} - std::move(e).transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = std::move(e).transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} } // Test const&& overload { const std::expected e; - std::move(e).transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = std::move(e).transform_error(return_unexpected); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} - std::move(e).transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} + std::ignore = std::move(e).transform_error(return_no_object); // expected-error-re@*:* {{static assertion failed {{.*}}The result of {{.*}} must be a valid template argument for unexpected}} // expected-error-re@*:* 0-1 {{{{(excess elements in struct initializer|no matching constructor for initialization of)}}{{.*}}}} } }