lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master f69b1a6 2/2: Enable '-Wdouble-promotion'


From: Greg Chicares
Subject: [lmi-commits] [lmi] master f69b1a6 2/2: Enable '-Wdouble-promotion'
Date: Thu, 21 Jun 2018 20:47:34 -0400 (EDT)

branch: master
commit f69b1a69848b08cff85f8427bfb5c95d47619ff7
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Enable '-Wdouble-promotion'
    
    Aside from wx, this affects only unit tests, because lmi does not use
    type float for its calculations.
---
 any_member_test.cpp |  2 +-
 callback_test.cpp   |  7 +++++++
 numeric_io_cast.hpp |  1 +
 pchfile_wx.hpp      |  2 ++
 round_to_test.cpp   |  9 +++++----
 tn_range_test.cpp   | 16 ++++++++--------
 workhorse.make      |  4 +++-
 7 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/any_member_test.cpp b/any_member_test.cpp
index 786c102..d39f725 100644
--- a/any_member_test.cpp
+++ b/any_member_test.cpp
@@ -562,7 +562,7 @@ void any_member_test::supplemental_test1()
     BOOST_TEST_EQUAL(999    , r0.i0);
     BOOST_TEST_EQUAL(888000 , r0.i1);
     BOOST_TEST_EQUAL(777.0  , r0.d0);
-    BOOST_TEST_EQUAL(8.125  , r0.q0);
+    BOOST_TEST_EQUAL(8.125f , r0.q0);
     BOOST_TEST_EQUAL("hello", r0.s0);
 
     T r1;
diff --git a/callback_test.cpp b/callback_test.cpp
index 3165912..f156011 100644
--- a/callback_test.cpp
+++ b/callback_test.cpp
@@ -68,7 +68,14 @@ namespace application
 
     double concrete_adder(int x, float y, double z)
     {
+#if defined __GNUC__
+#   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wdouble-promotion"
+#endif // defined __GNUC__
         return x + z + y;
+#if defined __GNUC__
+#   pragma GCC diagnostic pop
+#endif // defined __GNUC__
     }
 
     void initialize_callback()
diff --git a/numeric_io_cast.hpp b/numeric_io_cast.hpp
index 06e29bc..61233dc 100644
--- a/numeric_io_cast.hpp
+++ b/numeric_io_cast.hpp
@@ -216,6 +216,7 @@ struct numeric_converter<std::string, From>
         buffer[buffer_length] = '\0';
 #if defined __GNUC__
 #   pragma GCC diagnostic push
+#   pragma GCC diagnostic ignored "-Wdouble-promotion"
 #   pragma GCC diagnostic ignored "-Wformat-nonliteral"
 #endif // defined __GNUC__
         int actual_length = std::snprintf
diff --git a/pchfile_wx.hpp b/pchfile_wx.hpp
index 3471629..441a1ca 100644
--- a/pchfile_wx.hpp
+++ b/pchfile_wx.hpp
@@ -36,6 +36,8 @@
 // be disabled for the code using wxWidgets as they occur in wxWidgets headers.
 #if defined __GNUC__
 #   pragma GCC diagnostic ignored "-Wcast-qual"
+//  only 'strvararg.h:1048:19':
+#   pragma GCC diagnostic ignored "-Wdouble-promotion"
 #   pragma GCC diagnostic ignored "-Wformat-nonliteral"
 #   pragma GCC diagnostic ignored "-Wsign-conversion"
 #endif // defined __GNUC__
diff --git a/round_to_test.cpp b/round_to_test.cpp
index 670771f..03fb455 100644
--- a/round_to_test.cpp
+++ b/round_to_test.cpp
@@ -182,11 +182,12 @@ bool test_one_case
         // TODO ?? Shouldn't one epsilon here be epsilon of
         // max-precision-real type, as shown in a comment?
         // But consider using std::nextafter instead of (1+epsilon).
+        RealType const unity = 1;
         tolerance =
-               (1.0 + std::numeric_limits<RealType>::epsilon())
-             * (1.0 + std::numeric_limits<RealType>::epsilon())
-//           * (1.0 + std::numeric_limits<max_prec_real>::epsilon())
-             - 1.0
+               (unity + std::numeric_limits<RealType>::epsilon())
+             * (unity + std::numeric_limits<RealType>::epsilon())
+//           * (unity + std::numeric_limits<max_prec_real>::epsilon())
+             - unity
              ;
         }
 #if defined LMI_COMO_WITH_MINGW
diff --git a/tn_range_test.cpp b/tn_range_test.cpp
index 75ff60c..cbc4ee5 100644
--- a/tn_range_test.cpp
+++ b/tn_range_test.cpp
@@ -210,19 +210,19 @@ void 
tn_range_test::test_floating_auxiliary_functions(char const* file, int line
 
         // Test direction of adjustment.
 
-        INVOKE_BOOST_TEST_RELATION(-1.07, <=, adjust_bound(T(-1.07),  
std::numeric_limits<T>::max()), file, line);
-        INVOKE_BOOST_TEST_RELATION( 1.07, <=, adjust_bound(T( 1.07),  
std::numeric_limits<T>::max()), file, line);
+        INVOKE_BOOST_TEST_RELATION(T(-1.07), <=, adjust_bound(T(-1.07),  
std::numeric_limits<T>::max()), file, line);
+        INVOKE_BOOST_TEST_RELATION(T( 1.07), <=, adjust_bound(T( 1.07),  
std::numeric_limits<T>::max()), file, line);
 
-        INVOKE_BOOST_TEST_RELATION(-1.07, >=, adjust_bound(T(-1.07), 
-std::numeric_limits<T>::max()), file, line);
-        INVOKE_BOOST_TEST_RELATION( 1.07, >=, adjust_bound(T( 1.07), 
-std::numeric_limits<T>::max()), file, line);
+        INVOKE_BOOST_TEST_RELATION(T(-1.07), >=, adjust_bound(T(-1.07), 
-std::numeric_limits<T>::max()), file, line);
+        INVOKE_BOOST_TEST_RELATION(T( 1.07), >=, adjust_bound(T( 1.07), 
-std::numeric_limits<T>::max()), file, line);
 
         // Test inequality of original and adjusted values.
 
-        INVOKE_BOOST_TEST_RELATION(-1.07, <,  adjust_bound(T(-1.07),  
std::numeric_limits<T>::max()), file, line);
-        INVOKE_BOOST_TEST_RELATION( 1.07, <,  adjust_bound(T( 1.07),  
std::numeric_limits<T>::max()), file, line);
+        INVOKE_BOOST_TEST_RELATION(T(-1.07), <,  adjust_bound(T(-1.07),  
std::numeric_limits<T>::max()), file, line);
+        INVOKE_BOOST_TEST_RELATION(T( 1.07), <,  adjust_bound(T( 1.07),  
std::numeric_limits<T>::max()), file, line);
 
-        INVOKE_BOOST_TEST_RELATION(-1.07, >,  adjust_bound(T(-1.07), 
-std::numeric_limits<T>::max()), file, line);
-        INVOKE_BOOST_TEST_RELATION( 1.07, >,  adjust_bound(T( 1.07), 
-std::numeric_limits<T>::max()), file, line);
+        INVOKE_BOOST_TEST_RELATION(T(-1.07), >,  adjust_bound(T(-1.07), 
-std::numeric_limits<T>::max()), file, line);
+        INVOKE_BOOST_TEST_RELATION(T( 1.07), >,  adjust_bound(T( 1.07), 
-std::numeric_limits<T>::max()), file, line);
         }
 
     bool volatile is_iec559 = std::numeric_limits<T>::is_iec559;
diff --git a/workhorse.make b/workhorse.make
index 781a5fd..60c92ed 100644
--- a/workhorse.make
+++ b/workhorse.make
@@ -436,7 +436,7 @@ gcc_common_warnings := \
   -Wdangling-else \
   -Wdeprecated-declarations \
   -Wdisabled-optimization \
-  -Wno-double-promotion \
+  -Wdouble-promotion \
   -Wduplicated-branches \
   -Wduplicated-cond \
   -Wextra \
@@ -571,6 +571,8 @@ endif
 # Too many warnings for wx and various boost libraries:
 #  -Wold-style-cast \
 
+bourn_cast_test.o: gcc_common_extra_warnings += -Wno-double-promotion
+
 # SOMEDAY !! Address some of these '-Wconversion' issues.
 
 wno_conv_objects := \



reply via email to

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