From 2cc0c2cfbb3a63e02f3f7a8630c25143b204204a Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Wed, 25 Sep 2019 01:10:52 +0100 Subject: [PATCH] Clang: Remove -fms-extensions -fms-compatibility --- CMakeLists.txt | 2 -- Source/engine.cpp | 8 ++++---- Source/mpqapi.cpp | 2 +- Source/multi.cpp | 2 +- SourceS/miniwin.h | 10 ---------- SourceX/miniwin/misc.cpp | 16 ---------------- 6 files changed, 6 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b8c43e9b6..c97d06376 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -301,8 +301,6 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_compile_options(devilutionx PRIVATE -Wno-parentheses -Wno-logical-op-parentheses -Wno-bitwise-op-parentheses) # Silence warnings about __int64 alignment hack not always being applicable target_compile_options(devilutionx PRIVATE -Wno-ignored-attributes) - # Fix: error: cast from pointer to smaller type 'unsigned char' loses information - target_compile_options(devilution PRIVATE -fms-extensions -fms-compatibility -fms-compatibility-version=19.00) # Silence appfat.cpp warnings set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing") endif() diff --git a/Source/engine.cpp b/Source/engine.cpp index e3db8cb07..ed9c8de0e 100644 --- a/Source/engine.cpp +++ b/Source/engine.cpp @@ -264,14 +264,14 @@ void CelDecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int nW dst = pDecodeTo; tbl = &pLightTbl[light_table_index * 256]; w = nWidth; - shift = (BYTE)dst & 1; + shift = (BYTE)(size_t)dst & 1; for (; src != &pRLEBytes[nDataSize]; dst -= BUFFER_WIDTH + w, shift = (shift + 1) & 1) { for (i = w; i;) { width = *src++; if (!(width & 0x80)) { i -= width; - if (((BYTE)dst & 1) == shift) { + if (((BYTE)(size_t)dst & 1) == shift) { if (!(width & 1)) { goto L_ODD; } else { @@ -733,7 +733,7 @@ void Cel2DecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int n dst = pDecodeTo; tbl = &pLightTbl[light_table_index * 256]; w = nWidth; - shift = (BYTE)dst & 1; + shift = (BYTE)(size_t)dst & 1; for (; src != &pRLEBytes[nDataSize]; dst -= BUFFER_WIDTH + w, shift = (shift + 1) & 1) { for (i = w; i;) { @@ -741,7 +741,7 @@ void Cel2DecDatLightTrans(BYTE *pDecodeTo, BYTE *pRLEBytes, int nDataSize, int n if (!(width & 0x80)) { i -= width; if (dst < gpBufEnd) { - if (((BYTE)dst & 1) == shift) { + if (((BYTE)(size_t)dst & 1) == shift) { if (!(width & 1)) { goto L_ODD; } else { diff --git a/Source/mpqapi.cpp b/Source/mpqapi.cpp index 1951cbe29..a143901c6 100644 --- a/Source/mpqapi.cpp +++ b/Source/mpqapi.cpp @@ -88,7 +88,7 @@ void mpqapi_xor_buf(char *pbData) for (i = 0; i < 8; i++) { *pbCurrentData ^= mask; pbCurrentData++; - mask = _rotl(mask, 1); + mask = (mask << 1) | (mask >> 31); // _rotl(mask, 1) } } diff --git a/Source/multi.cpp b/Source/multi.cpp index 27c7c20bd..47a8e6c87 100644 --- a/Source/multi.cpp +++ b/Source/multi.cpp @@ -353,7 +353,7 @@ void multi_mon_seeds() DWORD l; sgdwGameLoops++; - l = _rotr(sgdwGameLoops, 8); + l = (sgdwGameLoops >> 8) | (sgdwGameLoops << 24); // _rotr(sgdwGameLoops, 8) for (i = 0; i < 200; i++) monster[i]._mAISeed = l + i; } diff --git a/SourceS/miniwin.h b/SourceS/miniwin.h index a59ad5d85..459d274cf 100644 --- a/SourceS/miniwin.h +++ b/SourceS/miniwin.h @@ -13,16 +13,6 @@ #include #include #include -// For _rotr() -// _rotl and _rotr are predeclared in Clang. -#if !defined(_MSC_VER) && !defined(__clang__) && defined(DEVILUTION_ENGINE) -#if defined(__x86_64__) || defined(__i386__) -#include -#else -unsigned int _rotl(unsigned int value, int shift); -unsigned int _rotr(unsigned int value, int shift); -#endif -#endif #ifndef _WIN32 #define __int8 char diff --git a/SourceX/miniwin/misc.cpp b/SourceX/miniwin/misc.cpp index a7f7e6c74..d42adf3f5 100644 --- a/SourceX/miniwin/misc.cpp +++ b/SourceX/miniwin/misc.cpp @@ -11,22 +11,6 @@ #define strncasecmp _strnicmp #endif -#if !defined(_MSC_VER) && !defined(__x86_64__) && !defined(__i386__) -unsigned int _rotl(unsigned int value, int shift) -{ - if ((shift &= 31) == 0) - return value; - return (value << shift) | (value >> (32 - shift)); -} - -unsigned int _rotr(unsigned int value, int shift) -{ - if ((shift &= 31) == 0) - return value; - return (value >> shift) | (value << (32 - shift)); -} -#endif - namespace dvl { DWORD last_error;