Tests ignore the return value of sto{meow}, triggering nodiscard warnings in MS STL

Reviewed By: #libc, Mordante

Differential Revision: https://reviews.llvm.org/D129925
This commit is contained in:
Igor Zhukov 2022-07-16 19:40:53 +02:00 committed by Mark de Wever
parent d8888e14a0
commit 844a320ccd
8 changed files with 58 additions and 58 deletions

View File

@ -60,7 +60,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stod("", &idx);
(void)std::stod("", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -69,7 +69,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stod(" - 8", &idx);
(void)std::stod(" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -78,7 +78,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stod("a1", &idx);
(void)std::stod("a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -127,7 +127,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stod(L"", &idx);
(void)std::stod(L"", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -136,7 +136,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stod(L" - 8", &idx);
(void)std::stod(L" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -145,7 +145,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stod(L"a1", &idx);
(void)std::stod(L"a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);

View File

@ -61,7 +61,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stof("", &idx);
(void)std::stof("", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -70,7 +70,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stof(" - 8", &idx);
(void)std::stof(" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -79,7 +79,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stof("a1", &idx);
(void)std::stof("a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -129,7 +129,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stof(L"", &idx);
(void)std::stof(L"", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -138,7 +138,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stof(L" - 8", &idx);
(void)std::stof(L" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -147,7 +147,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stof(L"a1", &idx);
(void)std::stof(L"a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);

View File

@ -32,7 +32,7 @@ int main(int, char**)
if (std::numeric_limits<long>::max() > std::numeric_limits<int>::max()) {
size_t idx = 0;
try {
std::stoi("0x100000000", &idx, 16);
(void)std::stoi("0x100000000", &idx, 16);
assert(false);
} catch (const std::out_of_range&) {
@ -41,7 +41,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoi("", &idx);
(void)std::stoi("", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -50,7 +50,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoi(" - 8", &idx);
(void)std::stoi(" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -59,7 +59,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoi("a1", &idx);
(void)std::stoi("a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -81,7 +81,7 @@ int main(int, char**)
if (std::numeric_limits<long>::max() > std::numeric_limits<int>::max()) {
size_t idx = 0;
try {
std::stoi(L"0x100000000", &idx, 16);
(void)std::stoi(L"0x100000000", &idx, 16);
assert(false);
} catch (const std::out_of_range&) {
@ -90,7 +90,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoi(L"", &idx);
(void)std::stoi(L"", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -99,7 +99,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoi(L" - 8", &idx);
(void)std::stoi(L" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -108,7 +108,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoi(L"a1", &idx);
(void)std::stoi(L"a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);

View File

@ -32,7 +32,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stol("", &idx);
(void)std::stol("", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -41,7 +41,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stol(" - 8", &idx);
(void)std::stol(" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -50,7 +50,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stol("a1", &idx);
(void)std::stol("a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -60,7 +60,7 @@ int main(int, char**)
size_t idx = 0;
try {
// LWG#2009 and PR14919
std::stol("9999999999999999999999999999999999999999999999999", &idx);
(void)std::stol("9999999999999999999999999999999999999999999999999", &idx);
assert(false);
} catch (const std::out_of_range&) {
assert(idx == 0);
@ -82,7 +82,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stol(L"", &idx);
(void)std::stol(L"", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -91,7 +91,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stol(L" - 8", &idx);
(void)std::stol(L" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -100,7 +100,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stol(L"a1", &idx);
(void)std::stol(L"a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -110,7 +110,7 @@ int main(int, char**)
size_t idx = 0;
try {
// LWG#2009 and PR14919
std::stol(L"9999999999999999999999999999999999999999999999999", &idx);
(void)std::stol(L"9999999999999999999999999999999999999999999999999", &idx);
assert(false);
} catch (const std::out_of_range&) {
assert(idx == 0);

View File

@ -49,7 +49,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stold("", &idx);
(void)std::stold("", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -58,7 +58,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stold(" - 8", &idx);
(void)std::stold(" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -67,7 +67,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stold("a1", &idx);
(void)std::stold("a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -113,7 +113,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stold(L"", &idx);
(void)std::stold(L"", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -122,7 +122,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stold(L" - 8", &idx);
(void)std::stold(L" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -131,7 +131,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stold(L"a1", &idx);
(void)std::stold(L"a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);

View File

@ -32,7 +32,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoll("", &idx);
(void)std::stoll("", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -41,7 +41,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoll(" - 8", &idx);
(void)std::stoll(" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -50,7 +50,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoll("a1", &idx);
(void)std::stoll("a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -60,7 +60,7 @@ int main(int, char**)
size_t idx = 0;
try {
// LWG#2009 and PR14919
std::stoll("99999999999999999999999999", &idx);
(void)std::stoll("99999999999999999999999999", &idx);
assert(false);
} catch (const std::out_of_range&) {
assert(idx == 0);
@ -82,7 +82,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoll(L"", &idx);
(void)std::stoll(L"", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -91,7 +91,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoll(L" - 8", &idx);
(void)std::stoll(L" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -100,7 +100,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoll(L"a1", &idx);
(void)std::stoll(L"a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -110,7 +110,7 @@ int main(int, char**)
size_t idx = 0;
try {
// LWG#2009 and PR14919
std::stoll(L"99999999999999999999999999", &idx);
(void)std::stoll(L"99999999999999999999999999", &idx);
assert(false);
} catch (const std::out_of_range&) {
assert(idx == 0);

View File

@ -31,7 +31,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoul("", &idx);
(void)std::stoul("", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -40,7 +40,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoul(" - 8", &idx);
(void)std::stoul(" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -49,7 +49,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoul("a1", &idx);
(void)std::stoul("a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -59,7 +59,7 @@ int main(int, char**)
size_t idx = 0;
try {
// LWG#2009 and PR14919
std::stoul("9999999999999999999999999999999999999999999999999", &idx);
(void)std::stoul("9999999999999999999999999999999999999999999999999", &idx);
assert(false);
} catch (const std::out_of_range&) {
assert(idx == 0);
@ -80,7 +80,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoul(L"", &idx);
(void)std::stoul(L"", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -89,7 +89,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoul(L" - 8", &idx);
(void)std::stoul(L" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -98,7 +98,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoul(L"a1", &idx);
(void)std::stoul(L"a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -108,7 +108,7 @@ int main(int, char**)
size_t idx = 0;
try {
// LWG#2009 and PR14919
std::stoul(L"9999999999999999999999999999999999999999999999999", &idx);
(void)std::stoul(L"9999999999999999999999999999999999999999999999999", &idx);
assert(false);
} catch (const std::out_of_range&) {
assert(idx == 0);

View File

@ -31,7 +31,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoull("", &idx);
(void)std::stoull("", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -40,7 +40,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoull(" - 8", &idx);
(void)std::stoull(" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -49,7 +49,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoull("a1", &idx);
(void)std::stoull("a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -59,7 +59,7 @@ int main(int, char**)
size_t idx = 0;
try {
// LWG#2009 and PR14919
std::stoull("9999999999999999999999999999999999999999999999999", &idx);
(void)std::stoull("9999999999999999999999999999999999999999999999999", &idx);
assert(false);
} catch (const std::out_of_range&) {
assert(idx == 0);
@ -80,7 +80,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoull(L"", &idx);
(void)std::stoull(L"", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -89,7 +89,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoull(L" - 8", &idx);
(void)std::stoull(L" - 8", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -98,7 +98,7 @@ int main(int, char**)
{
size_t idx = 0;
try {
std::stoull(L"a1", &idx);
(void)std::stoull(L"a1", &idx);
assert(false);
} catch (const std::invalid_argument&) {
assert(idx == 0);
@ -108,7 +108,7 @@ int main(int, char**)
size_t idx = 0;
try {
// LWG#2009 and PR14919
std::stoull(L"9999999999999999999999999999999999999999999999999", &idx);
(void)std::stoull(L"9999999999999999999999999999999999999999999999999", &idx);
assert(false);
} catch (const std::out_of_range&) {
assert(idx == 0);