You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
// Check that format functions are marked [[nodiscard]] as a conforming extension
10
+
11
+
// TODO FMT This test should not require std::to_chars(floating-point)
12
+
// XFAIL: availability-fp_to_chars-missing
13
+
14
+
// UNSUPPORTED: c++03, c++11, c++14 ,c++17
15
+
16
+
#include<format>
17
+
18
+
#include"test_macros.h"
19
+
20
+
#ifndef TEST_HAS_NO_LOCALIZATION
21
+
# include<locale>
22
+
#endif
23
+
24
+
voidtest() {
25
+
// clang-format off
26
+
std::format(""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
27
+
std::vformat("", std::make_format_args()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
28
+
std::formatted_size(""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
29
+
std::make_format_args(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
30
+
31
+
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
32
+
std::format(L""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
33
+
std::vformat(L"", std::make_wformat_args()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
34
+
std::formatted_size(L""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
35
+
std::make_wformat_args(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
36
+
#endif// TEST_HAS_NO_WIDE_CHARACTERS
37
+
38
+
#ifndef TEST_HAS_NO_LOCALIZATION
39
+
std::format(std::locale::classic(), ""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
40
+
std::vformat(std::locale::classic(), "", std::make_format_args()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
41
+
std::formatted_size(std::locale::classic(), ""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
42
+
# ifndef TEST_HAS_NO_WIDE_CHARACTERS
43
+
std::format(std::locale::classic(), L""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
44
+
std::vformat(std::locale::classic(), L"", std::make_wformat_args()); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
45
+
std::formatted_size(std::locale::classic(), L""); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
0 commit comments