[libcxx-commits] [libcxx] 9c053e6 - [libc++][format] Make public functions nodiscard.
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Jun 12 09:56:06 PDT 2023
Author: Mark de Wever
Date: 2023-06-12T18:55:56+02:00
New Revision: 9c053e69939b9d36723f7d5a9b00a6e3f1a9c726
URL: https://github.com/llvm/llvm-project/commit/9c053e69939b9d36723f7d5a9b00a6e3f1a9c726
DIFF: https://github.com/llvm/llvm-project/commit/9c053e69939b9d36723f7d5a9b00a6e3f1a9c726.diff
LOG: [libc++][format] Make public functions nodiscard.
This is an extension and only adds the functions that are a considered a
but when called and ignoring the result.
Drive-by sort all nodiscard extensions in the documentation.
Reviewed By: #libc, philnik
Differential Revision: https://reviews.llvm.org/D152097
Added:
libcxx/test/libcxx/diagnostics/format.nodiscard_extensions.compile.pass.cpp
libcxx/test/libcxx/diagnostics/format.nodiscard_extensions.verify.cpp
Modified:
libcxx/docs/UsingLibcxx.rst
libcxx/include/__format/format_functions.h
libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_format_args.sh.cpp
libcxx/test/std/utilities/format/format.functions/format.locale.verify.cpp
libcxx/test/std/utilities/format/format.functions/format.verify.cpp
libcxx/test/std/utilities/format/format.functions/formatted_size.locale.verify.cpp
libcxx/test/std/utilities/format/format.functions/formatted_size.verify.cpp
libcxx/test/std/utilities/format/format.tuple/format.functions.format.verify.cpp
Removed:
################################################################################
diff --git a/libcxx/docs/UsingLibcxx.rst b/libcxx/docs/UsingLibcxx.rst
index 703c324464e2e..3b22ac8274281 100644
--- a/libcxx/docs/UsingLibcxx.rst
+++ b/libcxx/docs/UsingLibcxx.rst
@@ -380,18 +380,30 @@ which no dialect declares as such (See the second form described above).
* ``adjacent_find``
* ``all_of``
* ``any_of``
+* ``as_const``
* ``binary_search``
+* ``bit_cast``
+* ``cbrt``
+* ``ceil``
* ``clamp``
+* ``copysign``
* ``count_if``
* ``count``
* ``equal_range``
* ``equal``
+* ``fabs``
* ``find_end``
* ``find_first_of``
* ``find_if_not``
* ``find_if``
* ``find``
+* ``floor``
+* ``fmax``
+* ``fmin``
+* ``forward``
+* ``fpclassify``
* ``get_temporary_buffer``
+* ``identity::operator()``
* ``includes``
* ``is_heap_until``
* ``is_heap``
@@ -399,8 +411,21 @@ which no dialect declares as such (See the second form described above).
* ``is_permutation``
* ``is_sorted_until``
* ``is_sorted``
+* ``isfinite``
+* ``isgreater``
+* ``isgreaterequal``
+* ``isinf``
+* ``isless``
+* ``islessequal``
+* ``islessgreater``
+* ``isnan``
+* ``isnormal``
+* ``isunordered``
* ``lexicographical_compare``
+* ``lock_guard``'s constructors
* ``lower_bound``
+* ``make_format_args``
+* ``make_wformat_args``
* ``max_element``
* ``max``
* ``min_element``
@@ -408,13 +433,10 @@ which no dialect declares as such (See the second form described above).
* ``minmax_element``
* ``minmax``
* ``mismatch``
+* ``move_if_noexcept``
+* ``move``
+* ``nearbyint``
* ``none_of``
-* ``remove_if``
-* ``remove``
-* ``search_n``
-* ``search``
-* ``unique``
-* ``upper_bound``
* ``ranges::adjacent_find``
* ``ranges::all_of``
* ``ranges::any_of``
@@ -453,38 +475,19 @@ which no dialect declares as such (See the second form described above).
* ``ranges::search``
* ``ranges::unique``
* ``ranges::upper_bound``
-* ``lock_guard``'s constructors
-* ``as_const``
-* ``bit_cast``
-* ``forward``
-* ``move``
-* ``move_if_noexcept``
-* ``identity::operator()``
-* ``to_integer``
-* ``to_underlying``
-* ``signbit``
-* ``fpclassify``
-* ``isfinite``
-* ``isinf``
-* ``isnan``
-* ``isnormal``
-* ``isgreater``
-* ``isgreaterequal``
-* ``isless``
-* ``islessequal``
-* ``islessgreater``
-* ``isunordered``
-* ``ceil``
-* ``fabs``
-* ``floor``
-* ``cbrt``
-* ``copysign``
-* ``fmax``
-* ``fmin``
-* ``nearbyint``
+* ``remove_if``
+* ``remove``
* ``rint``
* ``round``
+* ``search_n``
+* ``search``
+* ``signbit``
+* ``to_integer``
+* ``to_underlying``
* ``trunc``
+* ``unique``
+* ``upper_bound``
+* ``vformat``
Extended integral type support
------------------------------
diff --git a/libcxx/include/__format/format_functions.h b/libcxx/include/__format/format_functions.h
index 72a9f377d12b8..8bb40233477ec 100644
--- a/libcxx/include/__format/format_functions.h
+++ b/libcxx/include/__format/format_functions.h
@@ -65,16 +65,17 @@ using wformat_args = basic_format_args<wformat_context>;
#endif
template <class _Context = format_context, class... _Args>
-_LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&&... __args) {
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI __format_arg_store<_Context, _Args...> make_format_args(_Args&&... __args) {
return _VSTD::__format_arg_store<_Context, _Args...>(__args...);
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class... _Args>
-_LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...> make_wformat_args(_Args&&... __args) {
+_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI __format_arg_store<wformat_context, _Args...>
+make_wformat_args(_Args&&... __args) {
return _VSTD::__format_arg_store<wformat_context, _Args...>(__args...);
}
-#endif
+# endif
namespace __format {
@@ -442,38 +443,38 @@ format_to(_OutIt __out_it, wformat_string<_Args...> __fmt, _Args&&... __args) {
// TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup
// fires too eagerly, see http://llvm.org/PR61563.
template <class = void>
-_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string
+_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string
vformat(string_view __fmt, format_args __args) {
string __res;
_VSTD::vformat_to(_VSTD::back_inserter(__res), __fmt, __args);
return __res;
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
// TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup
// fires too eagerly, see http://llvm.org/PR61563.
template <class = void>
-_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring
+_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring
vformat(wstring_view __fmt, wformat_args __args) {
wstring __res;
_VSTD::vformat_to(_VSTD::back_inserter(__res), __fmt, __args);
return __res;
}
-#endif
+# endif
template <class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI string format(format_string<_Args...> __fmt,
- _Args&&... __args) {
+_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI string
+format(format_string<_Args...> __fmt, _Args&&... __args) {
return _VSTD::vformat(__fmt.get(), _VSTD::make_format_args(__args...));
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring
+_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring
format(wformat_string<_Args...> __fmt, _Args&&... __args) {
return _VSTD::vformat(__fmt.get(), _VSTD::make_wformat_args(__args...));
}
-#endif
+# endif
template <class _Context, class _OutIt, class _CharT>
_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_
diff erence_t<_OutIt> __n,
@@ -509,20 +510,20 @@ _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(basic_string_view<_CharT> __fmt,
}
template <class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
+_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
formatted_size(format_string<_Args...> __fmt, _Args&&... __args) {
return _VSTD::__vformatted_size(__fmt.get(), basic_format_args{_VSTD::make_format_args(__args...)});
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
+_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
formatted_size(wformat_string<_Args...> __fmt, _Args&&... __args) {
return _VSTD::__vformatted_size(__fmt.get(), basic_format_args{_VSTD::make_wformat_args(__args...)});
}
-#endif
+# endif
-#ifndef _LIBCPP_HAS_NO_LOCALIZATION
+# ifndef _LIBCPP_HAS_NO_LOCALIZATION
template <class _OutIt, class _CharT, class _FormatOutIt>
requires(output_iterator<_OutIt, const _CharT&>) _LIBCPP_HIDE_FROM_ABI _OutIt
@@ -577,7 +578,7 @@ format_to(_OutIt __out_it, locale __loc, wformat_string<_Args...> __fmt, _Args&&
// TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup
// fires too eagerly, see http://llvm.org/PR61563.
template <class = void>
-_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string
+_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI string
vformat(locale __loc, string_view __fmt, format_args __args) {
string __res;
_VSTD::vformat_to(_VSTD::back_inserter(__res), _VSTD::move(__loc), __fmt,
@@ -585,35 +586,34 @@ vformat(locale __loc, string_view __fmt, format_args __args) {
return __res;
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
// TODO FMT This needs to be a template or std::to_chars(floating-point) availability markup
// fires too eagerly, see http://llvm.org/PR61563.
template <class = void>
-_LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring
+_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE inline _LIBCPP_HIDE_FROM_ABI wstring
vformat(locale __loc, wstring_view __fmt, wformat_args __args) {
wstring __res;
_VSTD::vformat_to(_VSTD::back_inserter(__res), _VSTD::move(__loc), __fmt,
__args);
return __res;
}
-#endif
+# endif
template <class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI string format(locale __loc,
- format_string<_Args...> __fmt,
- _Args&&... __args) {
+_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI string
+format(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
return _VSTD::vformat(_VSTD::move(__loc), __fmt.get(),
_VSTD::make_format_args(__args...));
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring
+_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI wstring
format(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
return _VSTD::vformat(_VSTD::move(__loc), __fmt.get(),
_VSTD::make_wformat_args(__args...));
}
-#endif
+# endif
template <class _Context, class _OutIt, class _CharT>
_LIBCPP_HIDE_FROM_ABI format_to_n_result<_OutIt> __vformat_to_n(_OutIt __out_it, iter_
diff erence_t<_OutIt> __n,
@@ -654,21 +654,20 @@ _LIBCPP_HIDE_FROM_ABI size_t __vformatted_size(locale __loc, basic_string_view<_
}
template <class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
+_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
formatted_size(locale __loc, format_string<_Args...> __fmt, _Args&&... __args) {
return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.get(), basic_format_args{_VSTD::make_format_args(__args...)});
}
-#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class... _Args>
-_LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
+_LIBCPP_NODISCARD_EXT _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI size_t
formatted_size(locale __loc, wformat_string<_Args...> __fmt, _Args&&... __args) {
return _VSTD::__vformatted_size(_VSTD::move(__loc), __fmt.get(), basic_format_args{_VSTD::make_wformat_args(__args...)});
}
-#endif
-
-#endif // _LIBCPP_HAS_NO_LOCALIZATION
+# endif
+# endif // _LIBCPP_HAS_NO_LOCALIZATION
#endif //_LIBCPP_STD_VER >= 20
diff --git a/libcxx/test/libcxx/diagnostics/format.nodiscard_extensions.compile.pass.cpp b/libcxx/test/libcxx/diagnostics/format.nodiscard_extensions.compile.pass.cpp
new file mode 100644
index 0000000000000..e9ba2ae83b04c
--- /dev/null
+++ b/libcxx/test/libcxx/diagnostics/format.nodiscard_extensions.compile.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Check that format functions aren't marked [[nodiscard]] when
+// _LIBCPP_DISBALE_NODISCARD_EXT is defined
+
+// TODO FMT This test should not require std::to_chars(floating-point)
+// XFAIL: availability-fp_to_chars-missing
+
+// UNSUPPORTED: c++03, c++11, c++14 ,c++17
+
+// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_NODISCARD_EXT
+
+#include <format>
+
+#include "test_macros.h"
+
+#ifndef TEST_HAS_NO_LOCALIZATION
+# include <locale>
+#endif
+
+void test() {
+ std::format("");
+ std::vformat("", std::make_format_args());
+ std::formatted_size("");
+ std::make_format_args();
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+ std::format(L"");
+ std::vformat(L"", std::make_wformat_args());
+ std::formatted_size(L"");
+ std::make_wformat_args();
+#endif // TEST_HAS_NO_WIDE_CHARACTERS
+
+#ifndef TEST_HAS_NO_LOCALIZATION
+ std::format(std::locale::classic(), "");
+ std::vformat(std::locale::classic(), "", std::make_format_args());
+ std::formatted_size(std::locale::classic(), "");
+# ifndef TEST_HAS_NO_WIDE_CHARACTERS
+ std::format(std::locale::classic(), L"");
+ std::vformat(std::locale::classic(), L"", std::make_wformat_args());
+ std::formatted_size(std::locale::classic(), L"");
+# endif // TEST_HAS_NO_WIDE_CHARACTERS
+#endif // TEST_HAS_NO_LOCALIZATION
+}
diff --git a/libcxx/test/libcxx/diagnostics/format.nodiscard_extensions.verify.cpp b/libcxx/test/libcxx/diagnostics/format.nodiscard_extensions.verify.cpp
new file mode 100644
index 0000000000000..4af8210ce618d
--- /dev/null
+++ b/libcxx/test/libcxx/diagnostics/format.nodiscard_extensions.verify.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Check that format functions are marked [[nodiscard]] as a conforming extension
+
+// TODO FMT This test should not require std::to_chars(floating-point)
+// XFAIL: availability-fp_to_chars-missing
+
+// UNSUPPORTED: c++03, c++11, c++14 ,c++17
+
+#include <format>
+
+#include "test_macros.h"
+
+#ifndef TEST_HAS_NO_LOCALIZATION
+# include <locale>
+#endif
+
+void test() {
+ // clang-format off
+ std::format(""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ std::vformat("", std::make_format_args()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ std::formatted_size(""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ std::make_format_args(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+
+#ifndef TEST_HAS_NO_WIDE_CHARACTERS
+ std::format(L""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ std::vformat(L"", std::make_wformat_args()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ std::formatted_size(L""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ std::make_wformat_args(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+#endif // TEST_HAS_NO_WIDE_CHARACTERS
+
+#ifndef TEST_HAS_NO_LOCALIZATION
+ std::format(std::locale::classic(), ""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ std::vformat(std::locale::classic(), "", std::make_format_args()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ std::formatted_size(std::locale::classic(), ""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+# ifndef TEST_HAS_NO_WIDE_CHARACTERS
+ std::format(std::locale::classic(), L""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ std::vformat(std::locale::classic(), L"", std::make_wformat_args()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ std::formatted_size(std::locale::classic(), L""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+# endif // TEST_HAS_NO_WIDE_CHARACTERS
+#endif // TEST_HAS_NO_LOCALIZATION
+ // clang-format on
+}
diff --git a/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_format_args.sh.cpp b/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_format_args.sh.cpp
index 04b845cdffb0e..95a94b0bff5d0 100644
--- a/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_format_args.sh.cpp
+++ b/libcxx/test/std/utilities/format/format.arguments/format.arg.store/make_format_args.sh.cpp
@@ -21,7 +21,9 @@
#include <iterator>
#include <string>
+#include "test_macros.h"
+
void test() {
- std::make_format_args<std::basic_format_context<
- std::back_insert_iterator<std::basic_string<wchar_t>>, wchar_t>>('c');
+ TEST_IGNORE_NODISCARD
+ std::make_format_args<std::basic_format_context<std::back_insert_iterator<std::basic_string<wchar_t>>, wchar_t>>('c');
}
diff --git a/libcxx/test/std/utilities/format/format.functions/format.locale.verify.cpp b/libcxx/test/std/utilities/format/format.functions/format.locale.verify.cpp
index 0568181e636a4..8b06141a4f339 100644
--- a/libcxx/test/std/utilities/format/format.functions/format.locale.verify.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/format.locale.verify.cpp
@@ -28,65 +28,65 @@
// clang-format off
void f() {
- std::format(std::locale(), "{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), "{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), "}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), "}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), "{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), "{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), "{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), "{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), "{:-}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), "{:-}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), "{:#}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), "{:#}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), "{:L}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), "{:L}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), "{0:{0}}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), "{0:{0}}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), "{:.42d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), "{:.42d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), "{:d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), "{:d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- std::format(std::locale(), L"{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), L"{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), L"}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), L"}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), L"{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), L"{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), L"{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), L"{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), L"{:-}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), L"{:-}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), L"{:#}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), L"{:#}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), L"{:L}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), L"{:L}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), L"{0:{0}}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), L"{0:{0}}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), L"{:.42d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), L"{:.42d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(std::locale(), L"{:d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(std::locale(), L"{:d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
#endif
}
diff --git a/libcxx/test/std/utilities/format/format.functions/format.verify.cpp b/libcxx/test/std/utilities/format/format.functions/format.verify.cpp
index 3c9354835fce3..53b9b29fa72c6 100644
--- a/libcxx/test/std/utilities/format/format.functions/format.verify.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/format.verify.cpp
@@ -26,65 +26,65 @@
// clang-format off
void f() {
- std::format("{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format("{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format("}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format("}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format("{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format("{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format("{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format("{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format("{:-}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format("{:-}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format("{:#}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format("{:#}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format("{:L}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format("{:L}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format("{0:{0}}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format("{0:{0}}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format("{:.42d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format("{:.42d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format("{:d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format("{:d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- std::format(L"{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(L"{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(L"}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(L"}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(L"{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(L"{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(L"{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(L"{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(L"{:-}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(L"{:-}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(L"{:#}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(L"{:#}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(L"{:L}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(L"{:L}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(L"{0:{0}}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(L"{0:{0}}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(L"{:.42d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(L"{:.42d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(L"{:d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(L"{:d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
#endif
}
@@ -96,9 +96,9 @@ struct tiny {
void P2418()
{
auto t = tiny{};
- std::format("{}", t.bit); // expected-error{{non-const reference cannot bind to bit-field 'bit'}}
+ TEST_IGNORE_NODISCARD std::format("{}", t.bit); // expected-error{{non-const reference cannot bind to bit-field 'bit'}}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- std::format(L"{}", t.bit); // expected-error{{non-const reference cannot bind to bit-field 'bit'}}
+ TEST_IGNORE_NODISCARD std::format(L"{}", t.bit); // expected-error{{non-const reference cannot bind to bit-field 'bit'}}
#endif
}
diff --git a/libcxx/test/std/utilities/format/format.functions/formatted_size.locale.verify.cpp b/libcxx/test/std/utilities/format/format.functions/formatted_size.locale.verify.cpp
index 410e1ee2301d2..8ed848ec1fa0f 100644
--- a/libcxx/test/std/utilities/format/format.functions/formatted_size.locale.verify.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/formatted_size.locale.verify.cpp
@@ -30,65 +30,65 @@
// clang-format off
void f() {
- std::formatted_size(std::locale(), "{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), "{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), "}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), "}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), "{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), "{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), "{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), "{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), "{:-}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), "{:-}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), "{:#}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), "{:#}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), "{:L}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), "{:L}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), "{0:{0}}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), "{0:{0}}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), "{:.42d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), "{:.42d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), "{:d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), "{:d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- std::formatted_size(std::locale(), L"{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), L"{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), L"}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), L"}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), L"{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), L"{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), L"{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), L"{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), L"{:-}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), L"{:-}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), L"{:#}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), L"{:#}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), L"{:L}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), L"{:L}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), L"{0:{0}}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), L"{0:{0}}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), L"{:.42d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), L"{:.42d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(std::locale(), L"{:d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(std::locale(), L"{:d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
#endif
}
diff --git a/libcxx/test/std/utilities/format/format.functions/formatted_size.verify.cpp b/libcxx/test/std/utilities/format/format.functions/formatted_size.verify.cpp
index bc5fc682246b9..91b786e2213e4 100644
--- a/libcxx/test/std/utilities/format/format.functions/formatted_size.verify.cpp
+++ b/libcxx/test/std/utilities/format/format.functions/formatted_size.verify.cpp
@@ -26,65 +26,65 @@
// clang-format off
void f() {
- std::formatted_size("{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size("{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size("}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size("}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size("{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size("{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size("{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size("{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size("{:-}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size("{:-}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size("{:#}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size("{:#}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size("{:L}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size("{:L}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size("{0:{0}}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size("{0:{0}}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size("{:.42d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size("{:.42d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size("{:d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size("{:d}", "Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- std::formatted_size(L"{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(L"{"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(L"}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(L"}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(L"{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(L"{}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(L"{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(L"{0}"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(L"{:-}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(L"{:-}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(L"{:#}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(L"{:#}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(L"{:L}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(L"{:L}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(L"{0:{0}}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(L"{0:{0}}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(L"{:.42d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(L"{:.42d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::formatted_size(L"{:d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::formatted_size(L"{:d}", L"Forty-two"); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
#endif
}
diff --git a/libcxx/test/std/utilities/format/format.tuple/format.functions.format.verify.cpp b/libcxx/test/std/utilities/format/format.tuple/format.functions.format.verify.cpp
index 1c22e1b7d3782..a353339d51ca7 100644
--- a/libcxx/test/std/utilities/format/format.tuple/format.functions.format.verify.cpp
+++ b/libcxx/test/std/utilities/format/format.tuple/format.functions.format.verify.cpp
@@ -20,34 +20,34 @@
// clang-format off
void f() {
- std::format("{::}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format("{::}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format("{::^}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format("{::^}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format("{:+}", std::make_pair(0, 0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format("{:+}", std::make_pair(0, 0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format("{:m}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format("{:m}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format("{:m}", std::make_tuple(0, 0, 0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format("{:m}", std::make_tuple(0, 0, 0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
- std::format(L"{::}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(L"{::}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(L"{::^}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(L"{::^}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(L"{:+}", std::make_pair(0, 0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(L"{:+}", std::make_pair(0, 0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(L"{:m}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(L"{:m}", std::make_tuple(0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
- std::format(L"{:m}", std::make_tuple(0, 0, 0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
+ TEST_IGNORE_NODISCARD std::format(L"{:m}", std::make_tuple(0, 0, 0)); // expected-error-re{{call to consteval function '{{.*}}' is not a constant expression}}
// expected-note@*:* {{non-constexpr function '__throw_format_error' cannot be used in a constant expression}}
#endif
}
More information about the libcxx-commits
mailing list