From f038599ba697acc17a328ef4ade5514fede8887e Mon Sep 17 00:00:00 2001
From: Tobias Markmann <tm@ayena.de>
Date: Fri, 10 Jun 2016 14:38:40 +0200
Subject: Fix remaining compiler warnings on OS X with clang

This changes HippoMocks include to -isystem include so it will
not cause compiler warnings.

This changes UserLocation floating point values to double and
remove remaining numerical casts.

Change C++11 compiler test to not cause warnings.

Test-Information:

Builds with allow_warnings=0 on OS X 10.11.5 with Xcode clang.

Change-Id: I26c60265a86c9be656089ade63fe9ad63851580f

diff --git a/BuildTools/SCons/SConstruct b/BuildTools/SCons/SConstruct
index c5493fc..c3e64ee 100644
--- a/BuildTools/SCons/SConstruct
+++ b/BuildTools/SCons/SConstruct
@@ -87,9 +87,14 @@ int main(int, char **) {
 
     // lambda test
     auto someFunction = [](int i){ i = i * i; };
+    someFunction(2);
 
     // nullptr test
     double* fooDouble = nullptr;
+    double bazDouble = 8.0;
+    fooDouble = &bazDouble;
+    bazDouble = *fooDouble;
+
     return 0;
 }
 """, '.cpp')
diff --git a/QA/Checker/SConscript b/QA/Checker/SConscript
index 06ec01b..f8a3ce4 100644
--- a/QA/Checker/SConscript
+++ b/QA/Checker/SConscript
@@ -1,14 +1,20 @@
+import os
+
 Import("env")
 
 if env["TEST"] :
     if env["SCONS_STAGE"] == "flags" :
             env["CHECKER_FLAGS"] = {
-                    "CPPPATH" : ["#/3rdParty/HippoMocks"],
                     "LIBS": ["Checker"],
                     "LIBPATH": [Dir(".")],
                     "LINKFLAGS": env["PLATFORM"] == "win32" and ["/SUBSYSTEM:CONSOLE"] or []
                 }
 
+            if os.path.basename(env["CC"]) in ("clang", "gcc"):
+                env["CHECKER_FLAGS"]["CPPFLAGS"] = ["-isystem" + Dir("#/3rdParty/HippoMocks").abspath]
+            else :
+                env["CHECKER_FLAGS"]["CPPPATH"] = ["#/3rdParty/HippoMocks"]
+
     if env["SCONS_STAGE"] == "build" :
             checker_env = env.Clone()
             checker_env.UseFlags(env["SWIFTEN_FLAGS"])
diff --git a/Sluift/ElementConvertors/UserLocationConvertor.cpp b/Sluift/ElementConvertors/UserLocationConvertor.cpp
index 16ba41c..253ca36 100644
--- a/Sluift/ElementConvertors/UserLocationConvertor.cpp
+++ b/Sluift/ElementConvertors/UserLocationConvertor.cpp
@@ -8,8 +8,6 @@
 
 #include <memory>
 
-#include <boost/numeric/conversion/cast.hpp>
-
 #include <lua.hpp>
 
 #include <Swiften/Base/DateTime.h>
@@ -32,7 +30,7 @@ std::shared_ptr<UserLocation> UserLocationConvertor::doConvertFromLua(lua_State*
     lua_pop(L, 1);
     lua_getfield(L, -1, "altitude");
     if (lua_isnumber(L, -1)) {
-        result->setAltitude(boost::numeric_cast<float>(lua_tonumber(L, -1)));
+        result->setAltitude(lua_tonumber(L, -1));
     }
     lua_pop(L, 1);
     lua_getfield(L, -1, "locality");
@@ -42,12 +40,12 @@ std::shared_ptr<UserLocation> UserLocationConvertor::doConvertFromLua(lua_State*
     lua_pop(L, 1);
     lua_getfield(L, -1, "latitude");
     if (lua_isnumber(L, -1)) {
-        result->setLatitude(boost::numeric_cast<float>(lua_tonumber(L, -1)));
+        result->setLatitude(lua_tonumber(L, -1));
     }
     lua_pop(L, 1);
     lua_getfield(L, -1, "accuracy");
     if (lua_isnumber(L, -1)) {
-        result->setAccuracy(boost::numeric_cast<float>(lua_tonumber(L, -1)));
+        result->setAccuracy(lua_tonumber(L, -1));
     }
     lua_pop(L, 1);
     lua_getfield(L, -1, "description");
@@ -97,12 +95,12 @@ std::shared_ptr<UserLocation> UserLocationConvertor::doConvertFromLua(lua_State*
     lua_pop(L, 1);
     lua_getfield(L, -1, "longitude");
     if (lua_isnumber(L, -1)) {
-        result->setLongitude(boost::numeric_cast<float>(lua_tonumber(L, -1)));
+        result->setLongitude(lua_tonumber(L, -1));
     }
     lua_pop(L, 1);
     lua_getfield(L, -1, "error");
     if (lua_isnumber(L, -1)) {
-        result->setError(boost::numeric_cast<float>(lua_tonumber(L, -1)));
+        result->setError(lua_tonumber(L, -1));
     }
     lua_pop(L, 1);
     lua_getfield(L, -1, "postal_code");
@@ -112,7 +110,7 @@ std::shared_ptr<UserLocation> UserLocationConvertor::doConvertFromLua(lua_State*
     lua_pop(L, 1);
     lua_getfield(L, -1, "bearing");
     if (lua_isnumber(L, -1)) {
-        result->setBearing(boost::numeric_cast<float>(lua_tonumber(L, -1)));
+        result->setBearing(lua_tonumber(L, -1));
     }
     lua_pop(L, 1);
     lua_getfield(L, -1, "text");
@@ -132,7 +130,7 @@ std::shared_ptr<UserLocation> UserLocationConvertor::doConvertFromLua(lua_State*
     lua_pop(L, 1);
     lua_getfield(L, -1, "speed");
     if (lua_isnumber(L, -1)) {
-        result->setSpeed(boost::numeric_cast<float>(lua_tonumber(L, -1)));
+        result->setSpeed(lua_tonumber(L, -1));
     }
     lua_pop(L, 1);
     return result;
diff --git a/Swiften/Elements/UserLocation.h b/Swiften/Elements/UserLocation.h
index 7d07d6a..3bdaec6 100644
--- a/Swiften/Elements/UserLocation.h
+++ b/Swiften/Elements/UserLocation.h
@@ -31,11 +31,11 @@ namespace Swift {
                 this->area = value ;
             }
 
-            const boost::optional< float >& getAltitude() const {
+            const boost::optional< double >& getAltitude() const {
                 return altitude;
             }
 
-            void setAltitude(const boost::optional< float >& value) {
+            void setAltitude(const boost::optional< double >& value) {
                 this->altitude = value ;
             }
 
@@ -47,19 +47,19 @@ namespace Swift {
                 this->locality = value ;
             }
 
-            const boost::optional< float >& getLatitude() const {
+            const boost::optional< double >& getLatitude() const {
                 return latitude;
             }
 
-            void setLatitude(const boost::optional< float >& value) {
+            void setLatitude(const boost::optional< double >& value) {
                 this->latitude = value ;
             }
 
-            const boost::optional< float >& getAccuracy() const {
+            const boost::optional< double >& getAccuracy() const {
                 return accuracy;
             }
 
-            void setAccuracy(const boost::optional< float >& value) {
+            void setAccuracy(const boost::optional< double >& value) {
                 this->accuracy = value ;
             }
 
@@ -135,19 +135,19 @@ namespace Swift {
                 this->uri = value ;
             }
 
-            const boost::optional< float >& getLongitude() const {
+            const boost::optional< double >& getLongitude() const {
                 return longitude;
             }
 
-            void setLongitude(const boost::optional< float >& value) {
+            void setLongitude(const boost::optional< double >& value) {
                 this->longitude = value ;
             }
 
-            const boost::optional< float >& getError() const {
+            const boost::optional< double >& getError() const {
                 return error;
             }
 
-            void setError(const boost::optional< float >& value) {
+            void setError(const boost::optional< double >& value) {
                 this->error = value ;
             }
 
@@ -159,11 +159,11 @@ namespace Swift {
                 this->postalCode = value ;
             }
 
-            const boost::optional< float >& getBearing() const {
+            const boost::optional< double >& getBearing() const {
                 return bearing;
             }
 
-            void setBearing(const boost::optional< float >& value) {
+            void setBearing(const boost::optional< double >& value) {
                 this->bearing = value ;
             }
 
@@ -191,21 +191,21 @@ namespace Swift {
                 this->street = value ;
             }
 
-            const boost::optional< float >& getSpeed() const {
+            const boost::optional< double >& getSpeed() const {
                 return speed;
             }
 
-            void setSpeed(const boost::optional< float >& value) {
+            void setSpeed(const boost::optional< double >& value) {
                 this->speed = value ;
             }
 
 
         private:
             boost::optional< std::string > area;
-            boost::optional< float > altitude;
+            boost::optional< double > altitude;
             boost::optional< std::string > locality;
-            boost::optional< float > latitude;
-            boost::optional< float > accuracy;
+            boost::optional< double > latitude;
+            boost::optional< double > accuracy;
             boost::optional< std::string > description;
             boost::optional< std::string > countryCode;
             boost::optional< boost::posix_time::ptime > timestamp;
@@ -215,13 +215,13 @@ namespace Swift {
             boost::optional< std::string > country;
             boost::optional< std::string > region;
             boost::optional< std::string > uri;
-            boost::optional< float > longitude;
-            boost::optional< float > error;
+            boost::optional< double > longitude;
+            boost::optional< double > error;
             boost::optional< std::string > postalCode;
-            boost::optional< float > bearing;
+            boost::optional< double > bearing;
             boost::optional< std::string > text;
             boost::optional< std::string > datum;
             boost::optional< std::string > street;
-            boost::optional< float > speed;
+            boost::optional< double > speed;
     };
 }
diff --git a/Swiften/Parser/PayloadParsers/UnitTest/UserLocationParserTest.cpp b/Swiften/Parser/PayloadParsers/UnitTest/UserLocationParserTest.cpp
index 6d16377..98a147f 100644
--- a/Swiften/Parser/PayloadParsers/UnitTest/UserLocationParserTest.cpp
+++ b/Swiften/Parser/PayloadParsers/UnitTest/UserLocationParserTest.cpp
@@ -46,10 +46,10 @@ class UserLocationParserTest : public CppUnit::TestFixture
             UserLocation* payload = dynamic_cast<UserLocation*>(parser.getPayload().get());
             CPPUNIT_ASSERT(payload);
             CPPUNIT_ASSERT_EQUAL(std::string("Barbaric"), payload->getArea().get());
-            CPPUNIT_ASSERT_EQUAL(5.75F, payload->getAltitude().get());
+            CPPUNIT_ASSERT_EQUAL(5.75, payload->getAltitude().get());
             CPPUNIT_ASSERT_EQUAL(std::string("Near"), payload->getLocality().get());
-            CPPUNIT_ASSERT_EQUAL(1.670F, payload->getLatitude().get());
-            CPPUNIT_ASSERT_EQUAL(0.95F, payload->getAccuracy().get());
+            CPPUNIT_ASSERT_EQUAL(1.670, payload->getLatitude().get());
+            CPPUNIT_ASSERT_EQUAL(0.95, payload->getAccuracy().get());
             CPPUNIT_ASSERT_EQUAL(std::string("Nice"), payload->getDescription().get());
             CPPUNIT_ASSERT_EQUAL(std::string("+91"), payload->getCountryCode().get());
             CPPUNIT_ASSERT_EQUAL(std::string("2015-06-11T20:55:50Z"), dateTimeToString(payload->getTimestamp().get()));
@@ -59,14 +59,14 @@ class UserLocationParserTest : public CppUnit::TestFixture
             CPPUNIT_ASSERT_EQUAL(std::string("USA"), payload->getCountry().get());
             CPPUNIT_ASSERT_EQUAL(std::string("NewSode"), payload->getRegion().get());
             CPPUNIT_ASSERT_EQUAL(std::string("URIs"), payload->getURI().get());
-            CPPUNIT_ASSERT_EQUAL(6.7578F, payload->getLongitude().get());
-            CPPUNIT_ASSERT_EQUAL(5.66F, payload->getError().get());
+            CPPUNIT_ASSERT_EQUAL(6.7578, payload->getLongitude().get());
+            CPPUNIT_ASSERT_EQUAL(5.66, payload->getError().get());
             CPPUNIT_ASSERT_EQUAL(std::string("67"), payload->getPostalCode().get());
-            CPPUNIT_ASSERT_EQUAL(12.89F, payload->getBearing().get());
+            CPPUNIT_ASSERT_EQUAL(12.89, payload->getBearing().get());
             CPPUNIT_ASSERT_EQUAL(std::string("Hello"), payload->getText().get());
             CPPUNIT_ASSERT_EQUAL(std::string("Datee"), payload->getDatum().get());
             CPPUNIT_ASSERT_EQUAL(std::string("Highway"), payload->getStreet().get());
-            CPPUNIT_ASSERT_EQUAL(56.77F, payload->getSpeed().get());
+            CPPUNIT_ASSERT_EQUAL(56.77, payload->getSpeed().get());
         }
 
         void testParse_with_Some_variables() {
@@ -83,10 +83,10 @@ class UserLocationParserTest : public CppUnit::TestFixture
             UserLocation* payload = dynamic_cast<UserLocation*>(parser.getPayload().get());
             CPPUNIT_ASSERT(payload);
             CPPUNIT_ASSERT_EQUAL(std::string("Barbaric"), payload->getArea().get());
-            CPPUNIT_ASSERT_EQUAL(5.75F, payload->getAltitude().get());
+            CPPUNIT_ASSERT_EQUAL(5.75, payload->getAltitude().get());
             CPPUNIT_ASSERT_EQUAL(std::string("Near"), payload->getLocality().get());
             CPPUNIT_ASSERT(!payload->getLatitude());
-            CPPUNIT_ASSERT_EQUAL(0.95F, payload->getAccuracy().get());
+            CPPUNIT_ASSERT_EQUAL(0.95, payload->getAccuracy().get());
             CPPUNIT_ASSERT_EQUAL(std::string("Nice"), payload->getDescription().get());
             CPPUNIT_ASSERT_EQUAL(std::string("+91"), payload->getCountryCode().get());
             CPPUNIT_ASSERT_EQUAL(std::string("2015-06-11T20:55:50Z"), dateTimeToString(payload->getTimestamp().get()));
@@ -96,10 +96,10 @@ class UserLocationParserTest : public CppUnit::TestFixture
             CPPUNIT_ASSERT(!payload->getCountry());
             CPPUNIT_ASSERT_EQUAL(std::string("NewSode"), payload->getRegion().get());
             CPPUNIT_ASSERT_EQUAL(std::string("URIs"), payload->getURI().get());
-            CPPUNIT_ASSERT_EQUAL(6.7578F, payload->getLongitude().get());
-            CPPUNIT_ASSERT_EQUAL(5.66F, payload->getError().get());
+            CPPUNIT_ASSERT_EQUAL(6.7578, payload->getLongitude().get());
+            CPPUNIT_ASSERT_EQUAL(5.66, payload->getError().get());
             CPPUNIT_ASSERT_EQUAL(std::string("67"), payload->getPostalCode().get());
-            CPPUNIT_ASSERT_EQUAL(12.89F, payload->getBearing().get());
+            CPPUNIT_ASSERT_EQUAL(12.89, payload->getBearing().get());
             CPPUNIT_ASSERT_EQUAL(std::string("Hello"), payload->getText().get());
             CPPUNIT_ASSERT(!payload->getDatum());
             CPPUNIT_ASSERT(!payload->getStreet());
diff --git a/Swiften/Parser/PayloadParsers/UserLocationParser.cpp b/Swiften/Parser/PayloadParsers/UserLocationParser.cpp
index 77a0fa1..09d0e9a 100644
--- a/Swiften/Parser/PayloadParsers/UserLocationParser.cpp
+++ b/Swiften/Parser/PayloadParsers/UserLocationParser.cpp
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Isode Limited.
+ * Copyright (c) 2013-2016 Isode Limited.
  * All rights reserved.
  * See the COPYING file for more information.
  */
@@ -30,16 +30,16 @@ void UserLocationParser::handleEndElement(const std::string& element, const std:
     if (level == 1) {
         try {
             if (element == "accuracy") {
-                getPayloadInternal()->setAccuracy(boost::lexical_cast<float>(currentText));
+                getPayloadInternal()->setAccuracy(boost::lexical_cast<double>(currentText));
             }
             else if (element == "alt") {
-                getPayloadInternal()->setAltitude(boost::lexical_cast<float>(currentText));
+                getPayloadInternal()->setAltitude(boost::lexical_cast<double>(currentText));
             }
             else if (element == "area") {
                 getPayloadInternal()->setArea(currentText);
             }
             else if (element == "bearing") {
-                getPayloadInternal()->setBearing(boost::lexical_cast<float>(currentText));
+                getPayloadInternal()->setBearing(boost::lexical_cast<double>(currentText));
             }
             else if (element == "building") {
                 getPayloadInternal()->setBuilding(currentText);
@@ -57,19 +57,19 @@ void UserLocationParser::handleEndElement(const std::string& element, const std:
                 getPayloadInternal()->setDescription(currentText);
             }
             else if (element == "error") {
-                getPayloadInternal()->setError(boost::lexical_cast<float>(currentText));
+                getPayloadInternal()->setError(boost::lexical_cast<double>(currentText));
             }
             else if (element == "floor") {
                 getPayloadInternal()->setFloor(currentText);
             }
             else if (element == "lat") {
-                getPayloadInternal()->setLatitude(boost::lexical_cast<float>(currentText));
+                getPayloadInternal()->setLatitude(boost::lexical_cast<double>(currentText));
             }
             else if (element == "locality") {
                 getPayloadInternal()->setLocality(currentText);
             }
             else if (element == "lon") {
-                getPayloadInternal()->setLongitude(boost::lexical_cast<float>(currentText));
+                getPayloadInternal()->setLongitude(boost::lexical_cast<double>(currentText));
             }
             else if (element == "postalcode") {
                 getPayloadInternal()->setPostalCode(currentText);
@@ -81,7 +81,7 @@ void UserLocationParser::handleEndElement(const std::string& element, const std:
                 getPayloadInternal()->setRoom(currentText);
             }
             else if (element == "speed") {
-                getPayloadInternal()->setSpeed(boost::lexical_cast<float>(currentText));
+                getPayloadInternal()->setSpeed(boost::lexical_cast<double>(currentText));
             }
             else if (element == "street") {
                 getPayloadInternal()->setStreet(currentText);
diff --git a/Swiften/Serializer/PayloadSerializers/UnitTest/UserLocationSerializerTest.cpp b/Swiften/Serializer/PayloadSerializers/UnitTest/UserLocationSerializerTest.cpp
index 4c2121f..1a3adb9 100644
--- a/Swiften/Serializer/PayloadSerializers/UnitTest/UserLocationSerializerTest.cpp
+++ b/Swiften/Serializer/PayloadSerializers/UnitTest/UserLocationSerializerTest.cpp
@@ -33,10 +33,10 @@ class UserLocationSerializerTest : public CppUnit::TestFixture {
             UserLocationSerializer testling(&serializers);
             std::shared_ptr<UserLocation> userLocation(new UserLocation());
             userLocation->setArea(boost::optional<std::string>("Barbaric"));
-            userLocation->setAltitude(5.75F);
+            userLocation->setAltitude(5.75);
             userLocation->setLocality(boost::optional<std::string>("Near"));
-            userLocation->setLatitude(boost::optional<float>(5.75F));
-            userLocation->setAccuracy(5.75F);
+            userLocation->setLatitude(boost::optional<double>(5.75));
+            userLocation->setAccuracy(5.75);
             userLocation->setDescription(boost::optional<std::string>("Nice"));
             userLocation->setCountryCode(boost::optional<std::string>("+91"));
             userLocation->setTimestamp(stringToDateTime("2015-06-11T20:55:50Z"));
@@ -46,14 +46,14 @@ class UserLocationSerializerTest : public CppUnit::TestFixture {
             userLocation->setCountry(boost::optional<std::string>("USA"));
             userLocation->setRegion(boost::optional<std::string>("NewSode"));
             userLocation->setURI(boost::optional<std::string>("URIs"));
-            userLocation->setLongitude(5.75F);
-            userLocation->setError(5.75F);
+            userLocation->setLongitude(5.75);
+            userLocation->setError(5.75);
             userLocation->setPostalCode(boost::optional<std::string>("67"));
-            userLocation->setBearing(5.75F);
+            userLocation->setBearing(5.75);
             userLocation->setText(boost::optional<std::string>("Hello"));
             userLocation->setDatum(boost::optional<std::string>("Datee"));
             userLocation->setStreet(boost::optional<std::string>("Highway"));
-            userLocation->setSpeed(5.75F);
+            userLocation->setSpeed(5.75);
 
             std::string expectedResult =
                                 "<geoloc xmlns=\"http://jabber.org/protocol/geoloc\">"
@@ -72,19 +72,19 @@ class UserLocationSerializerTest : public CppUnit::TestFixture {
             UserLocationSerializer testling(&serializers);
             std::shared_ptr<UserLocation> userLocation(new UserLocation());
             userLocation->setArea(boost::optional<std::string>("Barbaric"));
-            userLocation->setAltitude(5.75F);
+            userLocation->setAltitude(5.75);
             userLocation->setLocality(boost::optional<std::string>("Near"));
-            userLocation->setAccuracy(5.75F);
+            userLocation->setAccuracy(5.75);
             userLocation->setDescription(boost::optional<std::string>("Nice"));
             userLocation->setCountryCode(boost::optional<std::string>("+91"));
             userLocation->setTimestamp(stringToDateTime("2015-06-11T20:55:50Z"));
             userLocation->setFloor(boost::optional<std::string>("3"));
             userLocation->setRegion(boost::optional<std::string>("NewSode"));
             userLocation->setURI(boost::optional<std::string>("URIs"));
-            userLocation->setLongitude(5.75F);
-            userLocation->setError(5.75F);
+            userLocation->setLongitude(5.75);
+            userLocation->setError(5.75);
             userLocation->setPostalCode(boost::optional<std::string>("67"));
-            userLocation->setBearing(5.75F);
+            userLocation->setBearing(5.75);
             userLocation->setText(boost::optional<std::string>("Hello"));
 
             std::string expectedResult =
-- 
cgit v0.10.2-6-g49f6