lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master bcb72b8 1/2: Fix -Wunused-variable from clang


From: Greg Chicares
Subject: [lmi-commits] [lmi] master bcb72b8 1/2: Fix -Wunused-variable from clang in the currency test
Date: Tue, 26 Oct 2021 16:27:47 -0400 (EDT)

branch: master
commit bcb72b820db8ed57f27269894aeb8c24a3fc03e4
Author: Vadim Zeitlin <vadim@tt-solutions.com>
Commit: Vadim Zeitlin <vadim@tt-solutions.com>

    Fix -Wunused-variable from clang in the currency test
    
    Unlike gcc, clang warns about unused constexpr variables too, so use
    stifle_warning_for_unused_variable() to suppress these warnings too,
    except for one case in which the variable was actually supposed to be
    used -- but wasn't.
---
 currency_test.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/currency_test.cpp b/currency_test.cpp
index e01901b..ccd4fdd 100644
--- a/currency_test.cpp
+++ b/currency_test.cpp
@@ -91,7 +91,7 @@ void currency_test::test_default_ctor()
     LMI_TEST(0.00 == a0.d());
     LMI_TEST(   0 == a0.m_);
     constexpr currency zero {};
-    LMI_TEST(   0 == a0.m_);
+    LMI_TEST(   0 == zero.m_);
 }
 
 void currency_test::test_copy_ctor()
@@ -166,7 +166,11 @@ void currency_test::test_literals()
     // These are evaluated at compile time, even though this is not
     // a constexpr context:
     auto compile_time_constant_pos( 9007199254740992_cents);
+    stifle_warning_for_unused_variable(compile_time_constant_pos);
+
     auto compile_time_constant_neg(-9007199254740992_cents);
+    stifle_warning_for_unused_variable(compile_time_constant_neg);
+
     // These would be compile-time errors:
 //  auto error_at_compile_time_pos( 9007199254740993_cents);
 //  auto error_at_compile_time_neg(-9007199254740993_cents);
@@ -293,6 +297,7 @@ void currency_test::mete_humongous()
     for(int i = 0; i < 100000; ++i)
         {
         currency volatile z = std::min(extreme, value);
+        stifle_warning_for_unused_variable(z);
         }
 }
 
@@ -304,6 +309,7 @@ void currency_test::mete_infinite()
     for(int i = 0; i < 100000; ++i)
         {
         currency volatile z = std::min(extreme, value);
+        stifle_warning_for_unused_variable(z);
         }
 }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]