lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 06024f1f 19/24: '-Wold-style-cast': treat cla


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 06024f1f 19/24: '-Wold-style-cast': treat clang the same as gcc
Date: Fri, 8 Jul 2022 07:11:28 -0400 (EDT)

branch: master
commit 06024f1fa1ae344d89f733f1085783dccdaabf14
Author: Gregory W. Chicares <gchicares@sbcglobal.net>
Commit: Gregory W. Chicares <gchicares@sbcglobal.net>

    '-Wold-style-cast': treat clang the same as gcc
---
 bourn_cast_test.cpp          | 12 ++++++------
 compiler_clang_warnings.make |  1 -
 fdlibm.hpp                   |  8 ++++----
 md5.cpp                      | 12 +++++++-----
 wx_utility.hpp               | 12 ++++++------
 5 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/bourn_cast_test.cpp b/bourn_cast_test.cpp
index 5f35b0e1..bae27970 100644
--- a/bourn_cast_test.cpp
+++ b/bourn_cast_test.cpp
@@ -631,9 +631,9 @@ void test_boost_anomalies()
     try
         {
         bourn_cast<int>(INT_MIN);
-        bourn_cast<int>((double)INT_MIN);
+        bourn_cast<int>(static_cast<double>(INT_MIN));
         // That worked, so this should too...
-        bourn_cast<int>((float)INT_MIN);
+        bourn_cast<int>(static_cast<float>(INT_MIN));
         // ...because INT_MIN = an exact power of 2.
         LMI_TEST(true);
         }
@@ -641,9 +641,9 @@ void test_boost_anomalies()
 
     try
         {
-        bourn_cast<long long int>((long double)LLONG_MIN);
+        bourn_cast<long long int>(static_cast<long double>(LLONG_MIN));
         // That worked, so this should too...
-        bourn_cast<long long int>((float)LLONG_MIN);
+        bourn_cast<long long int>(static_cast<float>(LLONG_MIN));
         // ...because LLONG_MIN = an exact power of 2.
         LMI_TEST(true);
         }
@@ -651,9 +651,9 @@ void test_boost_anomalies()
 
     try
         {
-        bourn_cast<long long int>((long double)LLONG_MIN);
+        bourn_cast<long long int>(static_cast<long double>(LLONG_MIN));
         // That worked, so this should too...
-        bourn_cast<long long int>((double)LLONG_MIN);
+        bourn_cast<long long int>(static_cast<double>(LLONG_MIN));
         // ...because LLONG_MIN = an exact power of 2.
         LMI_TEST(true);
         }
diff --git a/compiler_clang_warnings.make b/compiler_clang_warnings.make
index 543e387a..c56a01a8 100644
--- a/compiler_clang_warnings.make
+++ b/compiler_clang_warnings.make
@@ -80,7 +80,6 @@ clang_cxx_warnings := \
   -Wno-missing-noreturn \
   -Wno-missing-prototypes \
   -Wno-missing-variable-declarations \
-  -Wno-old-style-cast \
   -Wno-padded \
   -Wno-shadow \
   -Wno-sign-conversion \
diff --git a/fdlibm.hpp b/fdlibm.hpp
index 7b92c93d..b5997cd4 100644
--- a/fdlibm.hpp
+++ b/fdlibm.hpp
@@ -153,19 +153,19 @@ static inline uint32_t hi_uint(double d)
     return i;
 }
 
-#if defined __cplusplus && defined LMI_GCC
+#if defined __cplusplus && (defined LMI_GCC || defined LMI_CLANG)
 #   pragma GCC diagnostic push
 #   pragma GCC diagnostic ignored "-Wold-style-cast"
-#endif // defined __cplusplus && defined LMI_GCC
+#endif // defined __cplusplus && (defined LMI_GCC || defined LMI_CLANG)
 static inline int32_t hi_int(double d)
 {
     uint32_t i;
     GET_HIGH_WORD(i,d);
     return (int32_t)i;
 }
-#if defined __cplusplus && defined LMI_GCC
+#if defined __cplusplus && (defined LMI_GCC || defined LMI_CLANG)
 #   pragma GCC diagnostic pop
-#endif // defined __cplusplus && defined LMI_GCC
+#endif // defined __cplusplus && (defined LMI_GCC || defined LMI_CLANG)
 
 // Get the less significant 32 bit int from a double.
 
diff --git a/md5.cpp b/md5.cpp
index 0fac6f8c..f523ba6d 100644
--- a/md5.cpp
+++ b/md5.cpp
@@ -84,11 +84,13 @@
 # define SWAP(n) (n)
 #endif // !defined WORDS_BIGENDIAN
 
-#if defined LMI_GCC
+#if defined LMI_GCC || defined LMI_CLANG
 #   pragma GCC diagnostic push
 #   pragma GCC diagnostic ignored "-Wold-style-cast"
-#   pragma GCC diagnostic ignored "-Wuseless-cast"
-#endif // defined LMI_GCC
+#   if defined LMI_GCC
+#       pragma GCC diagnostic ignored "-Wuseless-cast"
+#   endif // defined LMI_GCC
+#endif // defined LMI_GCC || defined LMI_CLANG
 
 /* This array contains the bytes used to pad the buffer to the next
  * 64-byte boundary. (RFC 1321, 3.1: Step 1)
@@ -504,6 +506,6 @@ md5_process_block (void const* buffer, std::size_t a_len, 
md5_ctx* ctx)
   ctx->D = D;
 }
 
-#if defined LMI_GCC
+#if defined LMI_GCC || defined LMI_CLANG
 #   pragma GCC diagnostic pop
-#endif // defined LMI_GCC
+#endif // defined LMI_GCC || defined LMI_CLANG
diff --git a/wx_utility.hpp b/wx_utility.hpp
index 6404b2a9..69ff1ffa 100644
--- a/wx_utility.hpp
+++ b/wx_utility.hpp
@@ -46,21 +46,21 @@ class jdn_t;
 /// (C++98 5.4), which is inherently unsafe. Its sole virtue is that
 /// it is easily searched for.
 
-#if defined LMI_GCC
+#if defined LMI_GCC || defined LMI_CLANG
 #   pragma GCC diagnostic push
-#   if 8 <= __GNUC__
+#   if defined LMI_GCC && 8 <= __GNUC__
 #       pragma GCC diagnostic ignored "-Wcast-function-type"
-#   endif // 8 <= __GNUC__
+#   endif // defined LMI_GCC && 8 <= __GNUC__
 #   pragma GCC diagnostic ignored "-Wold-style-cast"
-#endif // defined LMI_GCC
+#endif // defined LMI_GCC || defined LMI_CLANG
 template<typename To, typename From>
 To c_cast(From z)
 {
     return (To)(z);
 }
-#if defined LMI_GCC
+#if defined LMI_GCC || defined LMI_CLANG
 #   pragma GCC diagnostic pop
-#endif // defined LMI_GCC
+#endif // defined LMI_GCC || defined LMI_CLANG
 
 /// Encapsulate wx clipboard.
 ///



reply via email to

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