0c7f9b3
From 01f62c02957cc1443ea761ddffe0b4322d987a1d Mon Sep 17 00:00:00 2001
0c7f9b3
From: Vadim Zeitlin <vadim@wxwidgets.org>
0c7f9b3
Date: Sun, 21 Jun 2015 15:56:06 +0200
0c7f9b3
Subject: [PATCH] Avoid warnings about narrowing casts in the long long tests.
0c7f9b3
0c7f9b3
Recent g++ versions give -Wnarrowing warning when a value outside of the type
0c7f9b3
range is used to initialize a variable of this type in { }. Avoid it in the
0c7f9b3
long long tests using explicit casts as we already cast between long long and
0c7f9b3
unsigned long long values here anyhow.
0c7f9b3
---
0c7f9b3
 tests/strings/strings.cpp | 19 +++++++++++--------
0c7f9b3
 1 file changed, 11 insertions(+), 8 deletions(-)
0c7f9b3
0c7f9b3
diff --git a/tests/strings/strings.cpp b/tests/strings/strings.cpp
0c7f9b3
index b016294..78a3a9d 100644
0c7f9b3
--- a/tests/strings/strings.cpp
0c7f9b3
+++ b/tests/strings/strings.cpp
0c7f9b3
@@ -589,14 +589,16 @@ enum
0c7f9b3
     Number_Long     = 16    // only for long tests
0c7f9b3
 };
0c7f9b3
 
0c7f9b3
+#ifdef wxLongLong_t
0c7f9b3
+typedef wxLongLong_t TestValue_t;
0c7f9b3
+#else
0c7f9b3
+typedef long TestValue_t;
0c7f9b3
+#endif
0c7f9b3
+
0c7f9b3
 static const struct ToLongData
0c7f9b3
 {
0c7f9b3
     const wxChar *str;
0c7f9b3
-#ifdef wxLongLong_t
0c7f9b3
-    wxLongLong_t value;
0c7f9b3
-#else
0c7f9b3
-    long value;
0c7f9b3
-#endif // wxLongLong_t
0c7f9b3
+    TestValue_t value;
0c7f9b3
     int flags;
0c7f9b3
     int base;
0c7f9b3
 
0c7f9b3
@@ -618,7 +620,7 @@ static const struct ToLongData
0c7f9b3
 
0c7f9b3
     { wxT("-1"), -1, Number_Signed | Number_Long },
0c7f9b3
     // this is surprising but consistent with strtoul() behaviour
0c7f9b3
-    { wxT("-1"), ULONG_MAX, Number_Unsigned | Number_Long },
0c7f9b3
+    { wxT("-1"), (TestValue_t)ULONG_MAX, Number_Unsigned | Number_Long },
0c7f9b3
 
0c7f9b3
     // this must overflow, even with 64 bit long
0c7f9b3
     { wxT("922337203685477580711"), 0, Number_Invalid },
0c7f9b3
@@ -626,8 +628,9 @@ static const struct ToLongData
0c7f9b3
 #ifdef wxLongLong_t
0c7f9b3
     { wxT("2147483648"), wxLL(2147483648), Number_LongLong },
0c7f9b3
     { wxT("-2147483648"), wxLL(-2147483648), Number_LongLong | Number_Signed },
0c7f9b3
-    { wxT("9223372036854775808"), wxULL(9223372036854775808), Number_LongLong |
0c7f9b3
-                                                             Number_Unsigned },
0c7f9b3
+    { wxT("9223372036854775808"),
0c7f9b3
+      TestValue_t(wxULL(9223372036854775808)),
0c7f9b3
+      Number_LongLong | Number_Unsigned },
0c7f9b3
 #endif // wxLongLong_t
0c7f9b3
 
0c7f9b3
     // Base tests.