[libcxx-commits] [libcxx] 844a320 - Tests ignore the return value of sto{meow}, triggering nodiscard warnings in MS STL

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sat Jul 16 10:46:45 PDT 2022


Author: Igor Zhukov
Date: 2022-07-16T19:46:34+02:00
New Revision: 844a320ccd612d482c37178e9d1c61617e6f5db7

URL: https://github.com/llvm/llvm-project/commit/844a320ccd612d482c37178e9d1c61617e6f5db7
DIFF: https://github.com/llvm/llvm-project/commit/844a320ccd612d482c37178e9d1c61617e6f5db7.diff

LOG: 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

Added: 
    

Modified: 
    libcxx/test/std/strings/string.conversions/stod.pass.cpp
    libcxx/test/std/strings/string.conversions/stof.pass.cpp
    libcxx/test/std/strings/string.conversions/stoi.pass.cpp
    libcxx/test/std/strings/string.conversions/stol.pass.cpp
    libcxx/test/std/strings/string.conversions/stold.pass.cpp
    libcxx/test/std/strings/string.conversions/stoll.pass.cpp
    libcxx/test/std/strings/string.conversions/stoul.pass.cpp
    libcxx/test/std/strings/string.conversions/stoull.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/strings/string.conversions/stod.pass.cpp b/libcxx/test/std/strings/string.conversions/stod.pass.cpp
index 2bab34d3cb23b..bc553adc4a7f0 100644
--- a/libcxx/test/std/strings/string.conversions/stod.pass.cpp
+++ b/libcxx/test/std/strings/string.conversions/stod.pass.cpp
@@ -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);

diff  --git a/libcxx/test/std/strings/string.conversions/stof.pass.cpp b/libcxx/test/std/strings/string.conversions/stof.pass.cpp
index 4f320ea30941d..da4bddd575015 100644
--- a/libcxx/test/std/strings/string.conversions/stof.pass.cpp
+++ b/libcxx/test/std/strings/string.conversions/stof.pass.cpp
@@ -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);

diff  --git a/libcxx/test/std/strings/string.conversions/stoi.pass.cpp b/libcxx/test/std/strings/string.conversions/stoi.pass.cpp
index d6290431e94e0..8a8ea645fc268 100644
--- a/libcxx/test/std/strings/string.conversions/stoi.pass.cpp
+++ b/libcxx/test/std/strings/string.conversions/stoi.pass.cpp
@@ -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);

diff  --git a/libcxx/test/std/strings/string.conversions/stol.pass.cpp b/libcxx/test/std/strings/string.conversions/stol.pass.cpp
index 4196646f84c3c..3f376933e4857 100644
--- a/libcxx/test/std/strings/string.conversions/stol.pass.cpp
+++ b/libcxx/test/std/strings/string.conversions/stol.pass.cpp
@@ -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);

diff  --git a/libcxx/test/std/strings/string.conversions/stold.pass.cpp b/libcxx/test/std/strings/string.conversions/stold.pass.cpp
index fd228c6a52624..abe8842fc6e09 100644
--- a/libcxx/test/std/strings/string.conversions/stold.pass.cpp
+++ b/libcxx/test/std/strings/string.conversions/stold.pass.cpp
@@ -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);

diff  --git a/libcxx/test/std/strings/string.conversions/stoll.pass.cpp b/libcxx/test/std/strings/string.conversions/stoll.pass.cpp
index a6d53e54e2beb..b8eb1b5c05fc2 100644
--- a/libcxx/test/std/strings/string.conversions/stoll.pass.cpp
+++ b/libcxx/test/std/strings/string.conversions/stoll.pass.cpp
@@ -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);

diff  --git a/libcxx/test/std/strings/string.conversions/stoul.pass.cpp b/libcxx/test/std/strings/string.conversions/stoul.pass.cpp
index 37e7f9d49a8de..b84891ecd2dcb 100644
--- a/libcxx/test/std/strings/string.conversions/stoul.pass.cpp
+++ b/libcxx/test/std/strings/string.conversions/stoul.pass.cpp
@@ -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);

diff  --git a/libcxx/test/std/strings/string.conversions/stoull.pass.cpp b/libcxx/test/std/strings/string.conversions/stoull.pass.cpp
index dcfc5832e2027..744dcab28c4d5 100644
--- a/libcxx/test/std/strings/string.conversions/stoull.pass.cpp
+++ b/libcxx/test/std/strings/string.conversions/stoull.pass.cpp
@@ -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);


        


More information about the libcxx-commits mailing list