From b5e306f7d89e82984a37824a3640bd67a5c45d61 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Wed, 14 Aug 2024 11:01:02 -0400
Subject: Enable /permissive- on MSVC for better standards conformance  (#2251)

* Enable /permissive- on MSVC for better C++ conformance and fix related errors

* Clean up left over warning suppressions from old library or msvc versions
---
 indra/newview/llappearancemgr.cpp          |  5 -----
 indra/newview/llappviewer.cpp              |  5 -----
 indra/newview/llcommandlineparser.cpp      | 14 --------------
 indra/newview/llgroupmgr.cpp               | 11 -----------
 indra/newview/llimprocessing.cpp           |  4 ----
 indra/newview/lllogchat.cpp                | 12 ------------
 indra/newview/llmediadataclient.cpp        |  5 -----
 indra/newview/llsecapi.h                   |  4 ++++
 indra/newview/llsechandler_basic.h         |  9 +++++++++
 indra/newview/llviewerjoystick.cpp         |  2 +-
 indra/newview/llviewerjoystick.h           |  2 +-
 indra/newview/llviewerprecompiledheaders.h |  5 -----
 indra/newview/llvoavatarself.cpp           | 11 -----------
 indra/newview/llwindebug.h                 |  3 ---
 14 files changed, 15 insertions(+), 77 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 66082d317a..946d674e8b 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -66,11 +66,6 @@
 
 #include "llavatarpropertiesprocessor.h"
 
-#if LL_MSVC
-// disable boost::lexical_cast warning
-#pragma warning (disable:4702)
-#endif
-
 namespace
 {
     const S32   BAKE_RETRY_MAX_COUNT = 5;
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index 262ab439b4..e39d9e7e20 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -269,11 +269,6 @@ using namespace LL;
 #include "glib.h"
 #endif // (LL_LINUX) && LL_GTK
 
-#if LL_MSVC
-// disable boost::lexical_cast warning
-#pragma warning (disable:4702)
-#endif
-
 static LLAppViewerListener sAppViewerListener(LLAppViewer::instance);
 
 ////// Windows-specific includes to the bottom - nasty defines in these pollute the preprocessor
diff --git a/indra/newview/llcommandlineparser.cpp b/indra/newview/llcommandlineparser.cpp
index f301af9511..f21bae9805 100644
--- a/indra/newview/llcommandlineparser.cpp
+++ b/indra/newview/llcommandlineparser.cpp
@@ -28,26 +28,12 @@
 #include "llcommandlineparser.h"
 #include "llexception.h"
 
-// *NOTE: The boost::lexical_cast generates
-// the warning C4701(local used with out assignment) in VC7.1.
-// Disable the warning for the boost includes.
-#if _MSC_VER
-#   pragma warning(push)
-#   pragma warning( disable : 4701 )
-#else
-// NOTE: For the other platforms?
-#endif
-
 #include <boost/program_options.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/bind.hpp>
 #include <boost/tokenizer.hpp>
 #include <boost/assign/list_of.hpp>
 
-#if _MSC_VER
-#   pragma warning(pop)
-#endif
-
 #include "llsdserialize.h"
 #include "llerror.h"
 #include "stringize.h"
diff --git a/indra/newview/llgroupmgr.cpp b/indra/newview/llgroupmgr.cpp
index 76d3e3e049..d53b36e59f 100644
--- a/indra/newview/llgroupmgr.cpp
+++ b/indra/newview/llgroupmgr.cpp
@@ -55,19 +55,8 @@
 #include "llcorehttputil.h"
 #include "lluiusage.h"
 
-
-#if LL_MSVC
-#pragma warning(push)
-// disable boost::lexical_cast warning
-#pragma warning (disable:4702)
-#endif
-
 #include <boost/lexical_cast.hpp>
 
-#if LL_MSVC
-#pragma warning(pop)   // Restore all warnings to the previous state
-#endif
-
 const U32 MAX_CACHED_GROUPS = 20;
 
 //
diff --git a/indra/newview/llimprocessing.cpp b/indra/newview/llimprocessing.cpp
index e24274650d..c1e68e0288 100644
--- a/indra/newview/llimprocessing.cpp
+++ b/indra/newview/llimprocessing.cpp
@@ -58,10 +58,6 @@
 #include "llworld.h"
 
 #include "boost/lexical_cast.hpp"
-#if LL_MSVC
-// disable boost::lexical_cast warning
-#pragma warning (disable:4702)
-#endif
 
 extern void on_new_message(const LLSD& msg);
 
diff --git a/indra/newview/lllogchat.cpp b/indra/newview/lllogchat.cpp
index 329fb881e3..bf49f33049 100644
--- a/indra/newview/lllogchat.cpp
+++ b/indra/newview/lllogchat.cpp
@@ -42,19 +42,7 @@
 #include <boost/algorithm/string/trim.hpp>
 #include <boost/algorithm/string/replace.hpp>
 #include <boost/regex.hpp>
-
-#if LL_MSVC
-#pragma warning(push)
-// disable warning about boost::lexical_cast unreachable code
-// when it fails to parse the string
-#pragma warning (disable:4702)
-#endif
-
 #include <boost/date_time/gregorian/gregorian.hpp>
-#if LL_MSVC
-#pragma warning(pop)   // Restore all warnings to the previous state
-#endif
-
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/date_time/local_time_adjustor.hpp>
 
diff --git a/indra/newview/llmediadataclient.cpp b/indra/newview/llmediadataclient.cpp
index 0f3e0306af..83a6e66019 100644
--- a/indra/newview/llmediadataclient.cpp
+++ b/indra/newview/llmediadataclient.cpp
@@ -29,11 +29,6 @@
 #include "llmediadataclient.h"
 #include "llviewercontrol.h"
 
-#if LL_MSVC
-// disable boost::lexical_cast warning
-#pragma warning (disable:4702)
-#endif
-
 #include <algorithm>
 #include <boost/lexical_cast.hpp>
 
diff --git a/indra/newview/llsecapi.h b/indra/newview/llsecapi.h
index 5cc78d09dc..ceea11cc34 100644
--- a/indra/newview/llsecapi.h
+++ b/indra/newview/llsecapi.h
@@ -35,6 +35,7 @@
 #include "llexception.h"
 
 #ifdef LL_WINDOWS
+#pragma warning (push)
 #pragma warning(disable:4250)
 #endif // LL_WINDOWS
 
@@ -549,5 +550,8 @@ void registerSecHandler(const std::string& handler_type,
 
 extern LLPointer<LLSecAPIHandler> gSecAPIHandler;
 
+#ifdef LL_WINDOWS
+#pragma warning (pop)
+#endif // LL_WINDOWS
 
 #endif // LL_SECAPI_H
diff --git a/indra/newview/llsechandler_basic.h b/indra/newview/llsechandler_basic.h
index 1484c6d0e1..2dffe84775 100644
--- a/indra/newview/llsechandler_basic.h
+++ b/indra/newview/llsechandler_basic.h
@@ -28,6 +28,11 @@
 #ifndef LLSECHANDLER_BASIC
 #define LLSECHANDLER_BASIC
 
+#ifdef LL_WINDOWS
+#pragma warning (push)
+#pragma warning(disable:4250)
+#endif // LL_WINDOWS
+
 #include "llsecapi.h"
 #include <vector>
 #include <openssl/x509.h>
@@ -346,6 +351,10 @@ protected:
 
 bool valueCompareLLSD(const LLSD& lhs, const LLSD& rhs);
 
+#ifdef LL_WINDOWS
+#pragma warning (pop)
+#endif // LL_WINDOWS
+
 #endif // LLSECHANDLER_BASIC
 
 
diff --git a/indra/newview/llviewerjoystick.cpp b/indra/newview/llviewerjoystick.cpp
index 787ea02e4c..7543fb3743 100644
--- a/indra/newview/llviewerjoystick.cpp
+++ b/indra/newview/llviewerjoystick.cpp
@@ -524,7 +524,7 @@ void LLViewerJoystick::initDevice(LLSD &guid)
 #endif
 }
 
-bool LLViewerJoystick::initDevice(void * preffered_device /*LPDIRECTINPUTDEVICE8*/, std::string &name, LLSD &guid)
+bool LLViewerJoystick::initDevice(void * preffered_device /*LPDIRECTINPUTDEVICE8*/, const std::string &name, const LLSD &guid)
 {
 #if LIB_NDOF
     mLastDeviceUUID = guid;
diff --git a/indra/newview/llviewerjoystick.h b/indra/newview/llviewerjoystick.h
index b459987c68..c989615653 100644
--- a/indra/newview/llviewerjoystick.h
+++ b/indra/newview/llviewerjoystick.h
@@ -56,7 +56,7 @@ public:
     void init(bool autoenable);
     void initDevice(LLSD &guid);
     bool initDevice(void * preffered_device /*LPDIRECTINPUTDEVICE8*/);
-    bool initDevice(void * preffered_device /*LPDIRECTINPUTDEVICE8*/, std::string &name, LLSD &guid);
+    bool initDevice(void * preffered_device /*LPDIRECTINPUTDEVICE8*/, const std::string &name, const LLSD &guid);
     void terminate();
 
     void updateStatus();
diff --git a/indra/newview/llviewerprecompiledheaders.h b/indra/newview/llviewerprecompiledheaders.h
index 8398cd8a54..6561f0d644 100644
--- a/indra/newview/llviewerprecompiledheaders.h
+++ b/indra/newview/llviewerprecompiledheaders.h
@@ -37,11 +37,6 @@
 
 #include "linden_common.h"
 
-// Work around stupid Microsoft STL warning
-#ifdef LL_WINDOWS
-#pragma warning (disable : 4702) // warning C4702: unreachable code
-#endif
-
 #include <algorithm>
 #include <deque>
 #include <functional>
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index 57f7734fea..00a7325db2 100644
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -24,12 +24,6 @@
  * $/LicenseInfo$
  */
 
-#if LL_MSVC
-// disable warning about boost::lexical_cast returning uninitialized data
-// when it fails to parse the string
-#pragma warning (disable:4701)
-#endif
-
 #include "llviewerprecompiledheaders.h"
 
 #include "llvoavatarself.h"
@@ -69,11 +63,6 @@
 #include "llcorehttputil.h"
 #include "lluiusage.h"
 
-#if LL_MSVC
-// disable boost::lexical_cast warning
-#pragma warning (disable:4702)
-#endif
-
 #include <boost/lexical_cast.hpp>
 
 LLPointer<LLVOAvatarSelf> gAgentAvatarp = NULL;
diff --git a/indra/newview/llwindebug.h b/indra/newview/llwindebug.h
index d2801c86e1..770584c88d 100644
--- a/indra/newview/llwindebug.h
+++ b/indra/newview/llwindebug.h
@@ -30,10 +30,7 @@
 #include "stdtypes.h"
 #include "llwin32headerslean.h"
 
-#pragma warning (push)
-#pragma warning (disable:4091) // a microsoft header has warnings. Very nice.
 #include <dbghelp.h>
-#pragma warning (pop)
 
 class LLWinDebug:
     public LLSingleton<LLWinDebug>
-- 
cgit v1.2.3