Remove compiler warning suppression (#66234)
authorAaron Robinson <arobins@microsoft.com>
Wed, 9 Mar 2022 00:57:12 +0000 (19:57 -0500)
committerGitHub <noreply@github.com>
Wed, 9 Mar 2022 00:57:12 +0000 (16:57 -0800)
* Remove 4996

* Remove 4701

* Remove 4611

* Remove 4610

* Remove 4510

* Remove 4267

* Remove 4267 - libunwind

18 files changed:
src/coreclr/debug/daccess/daccess.cpp
src/coreclr/jit/eeinterface.cpp
src/coreclr/jit/optimizer.cpp
src/coreclr/pal/inc/pal.h
src/coreclr/pal/src/libunwind/CMakeLists.txt
src/coreclr/pal/src/libunwind/include/mempool.h
src/coreclr/pal/src/libunwind/libunwind-version.txt
src/coreclr/pal/src/libunwind/src/dwarf/Gfind_proc_info-lsb.c
src/coreclr/pal/src/safecrt/input.inl
src/coreclr/pal/src/safecrt/internal.h
src/coreclr/tools/superpmi/superpmi-shared/standardpch.h
src/coreclr/vm/codeman.cpp
src/coreclr/vm/common.h
src/coreclr/vm/eehash.cpp
src/coreclr/vm/fcall.h
src/coreclr/vm/object.cpp
src/coreclr/vm/reflectioninvocation.cpp
src/coreclr/vm/virtualcallstub.h

index 7936b3a..7e7e5fe 100644 (file)
@@ -209,15 +209,8 @@ GetFullMethodNameFromMetadata(IMDInternalImport* mdImport,
 
     LPCUTF8 methodName;
     IfFailRet(mdImport->GetNameOfMethodDef(methodToken, &methodName));
-// Review conversion of size_t to ULONG32.
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:4267)
-#endif
+
     len = strlen(methodName);
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
     if (len >= bufferChars)
     {
         return E_OUTOFMEMORY;
index 9976b3d..60c685e 100644 (file)
@@ -21,9 +21,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
 #if defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD)
 
-#pragma warning(push)
-#pragma warning(disable : 4701) // difficult to get rid of C4701 with 'sig' below
-
 /*****************************************************************************/
 
 /*****************************************************************************
@@ -246,8 +243,6 @@ const char* Compiler::eeGetMethodFullName(CORINFO_METHOD_HANDLE hnd)
     return (retName);
 }
 
-#pragma warning(pop)
-
 #endif // defined(DEBUG) || defined(FEATURE_JIT_METHOD_PERF) || defined(FEATURE_SIMD)
 
 /*****************************************************************************/
index 9bcefc7..d87dcae 100644 (file)
@@ -13,7 +13,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 #include "jitpch.h"
 #ifdef _MSC_VER
 #pragma hdrstop
-#pragma warning(disable : 4701)
 #endif
 
 /*****************************************************************************/
@@ -7365,9 +7364,9 @@ void Compiler::fgCreateLoopPreHeader(unsigned lnum)
 
             if (allValidProfileWeights)
             {
-                weight_t loopEnteredCount;
-                weight_t loopSkippedCount;
-                bool     useEdgeWeights = fgHaveValidEdgeWeights;
+                weight_t loopEnteredCount = 0;
+                weight_t loopSkippedCount = 0;
+                bool     useEdgeWeights   = fgHaveValidEdgeWeights;
 
                 if (useEdgeWeights)
                 {
index 9d9a437..b74c5b9 100644 (file)
@@ -5037,10 +5037,6 @@ public:
 
 #define PAL_CPP_ENDTRY                  }
 
-#ifdef _MSC_VER
-#pragma warning(disable:4611) // interaction between '_setjmp' and C++ object destruction is non-portable
-#endif
-
 #define PAL_TRY_FOR_DLLMAIN(ParamType, paramDef, paramRef, _reason) PAL_TRY(ParamType, paramDef, paramRef)
 
 #endif // __cplusplus
index 2e19c38..4fc0240 100644 (file)
@@ -159,7 +159,6 @@ if(CLR_CMAKE_HOST_WIN32)
     add_compile_options(-wd4068) # ignore unknown pragma warnings (gcc pragmas)
     add_compile_options(-wd4146) # minus operator applied to unsigned
     add_compile_options(-wd4244) # possible loss of data
-    add_compile_options(-wd4267) # possible loss of data
     add_compile_options(-wd4334) # 32-bit shift implicitly converted to 64 bits
 
     # Disable warning due to incorrect format specifier in debugging printf via the Debug macro
index 1f1c770..60b9137 100644 (file)
@@ -63,8 +63,8 @@ struct mempool
     pthread_mutex_t lock;
     size_t obj_size;            /* object size (rounded up for alignment) */
     size_t chunk_size;          /* allocation granularity */
-    unsigned int reserve;       /* minimum (desired) size of the free-list */
-    unsigned int num_free;      /* number of objects on the free-list */
+    size_t reserve;             /* minimum (desired) size of the free-list */
+    size_t num_free;            /* number of objects on the free-list */
     struct object
       {
         struct object *next;
index fbc2538..c118043 100644 (file)
@@ -5,6 +5,7 @@ Replace CMakeLists.txt, src/CMakeLists.txt, configure.cmake with .NET custom ver
 Keep .NET oop directory
 Reapply changes from https://github.com/dotnet/runtime/commit/1b5719c2e3dde393531eaeb5b5cde05dabeef5b8
 Apply https://github.com/libunwind/libunwind/pull/317
+Apply https://github.com/libunwind/libunwind/pull/333
 
 For LoongArch64:
 Apply https://github.com/libunwind/libunwind/pull/316 and https://github.com/libunwind/libunwind/pull/322
index 7f17091..1bfba29 100644 (file)
@@ -866,9 +866,9 @@ remote_lookup (unw_addr_space_t as,
                unw_word_t table, size_t table_size, int32_t rel_ip,
                struct table_entry *e, int32_t *last_ip_offset, void *arg)
 {
-  unsigned long table_len = table_size / sizeof (struct table_entry);
+  size_t table_len = table_size / sizeof (struct table_entry);
   unw_accessors_t *a = unw_get_accessors_int (as);
-  unsigned long lo, hi, mid;
+  size_t lo, hi, mid;
   unw_word_t e_addr = 0;
   int32_t start = 0;
   int ret;
index 54b6296..3f415d6 100644 (file)
@@ -40,9 +40,6 @@
 
 #define UNALIGNED
 
-#define _BEGIN_SECURE_CRT_DEPRECATION_DISABLE
-#define _END_SECURE_CRT_DEPRECATION_DISABLE
-
 #define _CVTBUFSIZE (309+40) /* # of digits in max. dp value + slop */
 
 #define _MBTOWC(x,y,z) _minimal_chartowchar( x, y )
@@ -695,16 +692,12 @@ scanit:
                                     /* convert wide to multibyte */
                                     if (array_width >= ((size_t)MB_CUR_MAX))
                                     {
-_BEGIN_SECURE_CRT_DEPRECATION_DISABLE
                                         temp = wctomb((char *)pointer, ch);
-_END_SECURE_CRT_DEPRECATION_DISABLE
                                     }
                                     else
                                     {
                                         char tmpbuf[MB_LEN_MAX];
-_BEGIN_SECURE_CRT_DEPRECATION_DISABLE
                                         temp = wctomb(tmpbuf, ch);
-_END_SECURE_CRT_DEPRECATION_DISABLE
                                         if (temp > 0 && ((size_t)temp) > array_width)
                                         {
                                             /* We have exhausted the user's buffer */
index 02f8f80..8497c9f 100644 (file)
@@ -1033,16 +1033,6 @@ _CRTIMP void * __cdecl _decode_pointer(void *);
 /* internal helper function for communicating with the debugger */
 BOOL DebuggerKnownHandle();
 
-/* Macros to simplify the use of Secure CRT in the CRT itself.
- * We should use [_BEGIN/_END]_SECURE_CRT_DEPRECATION_DISABLE sparingly.
- */
-#define _BEGIN_SECURE_CRT_DEPRECATION_DISABLE \
-    __pragma(warning(push)) \
-    __pragma(warning(disable:4996))
-
-#define _END_SECURE_CRT_DEPRECATION_DISABLE \
-    __pragma(warning(pop))
-
 #define _ERRCHECK(e) \
     _INVOKE_WATSON_IF_ERROR(e)
 
index 1dfae36..33bdca9 100644 (file)
@@ -24,8 +24,6 @@
 #endif // INTERNAL_BUILD
 
 #ifdef _MSC_VER
-#pragma warning(disable : 4996) // The compiler encountered a deprecated declaration.
-
 // On Windows, we build against PAL macros that convert to Windows SEH. But we don't want all the
 // Contract stuff that normally gets pulled it. Defining JIT_BUILD prevents this, just as it does
 // when building the JIT using parts of utilcode.
index d039d00..ef4c0b8 100644 (file)
@@ -5468,21 +5468,11 @@ static void EnumRuntimeFunctionEntriesToFindEntry(PTR_RUNTIME_FUNCTION pRtf, PTR
         return;
     }
 
-    // Review conversion of size_t to ULONG.
-#if defined(_MSC_VER)
-#pragma warning(push)
-#pragma warning(disable:4267)
-#endif // defined(_MSC_VER)
+    UINT_PTR indexToLocate = pRtf - firstFunctionEntry;
 
-    ULONG indexToLocate = pRtf - firstFunctionEntry;
-
-#if defined(_MSC_VER)
-#pragma warning(pop)
-#endif // defined(_MSC_VER)
-
-    ULONG low = 0; // index in the function entry table of low end of search range
-    ULONG high = (pProgramExceptionsDirectory->Size) / sizeof(T_RUNTIME_FUNCTION) - 1; // index of high end of search range
-    ULONG mid = (low + high) / 2; // index of entry to be compared
+    UINT_PTR low = 0; // index in the function entry table of low end of search range
+    UINT_PTR high = (pProgramExceptionsDirectory->Size) / sizeof(T_RUNTIME_FUNCTION) - 1; // index of high end of search range
+    UINT_PTR mid = (low + high) / 2; // index of entry to be compared
 
     if (indexToLocate > high)
     {
index eb37c0a..07edf43 100644 (file)
 
     // These don't seem useful, so turning them off is no big deal
 #pragma warning(disable:4201)   // nameless struct/union
-#pragma warning(disable:4510)   // can't generate default constructor
-//#pragma warning(disable:4511)   // can't generate copy constructor
 #pragma warning(disable:4512)   // can't generate assignment constructor
-#pragma warning(disable:4610)   // user defined constructor required
 #pragma warning(disable:4211)   // nonstandard extention used (char name[0] in structs)
 #pragma warning(disable:4268)   // 'const' static/global data initialized with compiler generated default constructor fills the object with zeros
 #pragma warning(disable:4238)   // nonstandard extension used : class rvalue used as lvalue
@@ -38,8 +35,6 @@
 
     // Depending on the code base, you may want to not disable these
 #pragma warning(disable:4245)   // assigning signed / unsigned
-//#pragma warning(disable:4146)   // unary minus applied to unsigned
-//#pragma warning(disable:4244)   // loss of data int -> char ..
 #pragma warning(disable:4127)   // conditional expression is constant
 #pragma warning(disable:4100)   // unreferenced formal parameter
 
@@ -47,7 +42,6 @@
 
 #ifndef DEBUG
 #pragma warning(disable:4505)   // unreferenced local function has been removed
-//#pragma warning(disable:4702)   // unreachable code
 #pragma warning(disable:4313)   // 'format specifier' in format string conflicts with argument %d of type 'type'
 #endif // !DEBUG
 
@@ -56,9 +50,6 @@
 #pragma warning(disable:4710)   // function not inlined
 #pragma warning(disable:4527)   // user-defined destructor required
 #pragma warning(disable:4513)   // destructor could not be generated
-
-    // <TODO>TODO we really probably need this one put back in!!!</TODO>
-//#pragma warning(disable:4701)   // local variable may be used without being initialized
 #endif // _MSC_VER
 
 #define _CRT_DEPENDENCY_   //this code depends on the crt file functions
index 39054c7..280c273 100644 (file)
@@ -32,17 +32,9 @@ EEHashEntry_t * EEUtf8HashTableHelper::AllocateEntry(LPCUTF8 pKey, BOOL bDeepCop
 
     if (bDeepCopy)
     {
-        DWORD StringLen = (DWORD)strlen(pKey);
-        DWORD BufLen = 0;
-// Review conversion of size_t to DWORD.
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:4267)
-#endif
-        if (!ClrSafeInt<DWORD>::addition(StringLen, SIZEOF_EEHASH_ENTRY + sizeof(LPUTF8) + 1, BufLen))
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
+        SIZE_T StringLen = strlen(pKey);
+        SIZE_T BufLen = 0;
+        if (!ClrSafeInt<SIZE_T>::addition(StringLen, SIZEOF_EEHASH_ENTRY + sizeof(LPUTF8) + 1, BufLen))
             return NULL;
         pEntry = (EEHashEntry_t *) new (nothrow) BYTE[BufLen];
         if (!pEntry)
index e081605..8bed3fb 100644 (file)
 //
 #include <setjmp.h>
 
-//
-// Use of setjmp is temporary, we will eventually have compiler intrinsics to
-// disable the optimizations.  Besides, we don't actually execute setjmp in
-// these macros (or anywhere else in the VM on AMD64).
-//
-#pragma warning(disable:4611) // interaction between '_setjmp' and C++ object destruction is non-portable
-
 #ifdef _DEBUG
 //
 // Linked list of unmanaged methods preceeding a HelperMethodFrame push.  This
index 9cb54ed..dabc517 100644 (file)
@@ -1488,10 +1488,6 @@ void StackTraceArray::EnsureThreadAffinity()
     }
 }
 
-#ifdef _MSC_VER
-#pragma warning(disable: 4267)
-#endif
-
 // Deep copies the stack trace array
 void StackTraceArray::CopyFrom(StackTraceArray const & src)
 {
@@ -1516,11 +1512,6 @@ void StackTraceArray::CopyFrom(StackTraceArray const & src)
     SetObjectThread();  // affinitize the newly created array with the current thread
 }
 
-#ifdef _MSC_VER
-#pragma warning(default: 4267)
-#endif
-
-
 #ifdef _DEBUG
 //===============================================================================
 // Code that insures that our unmanaged version of Nullable is consistant with
index e49ad88..2b403a3 100644 (file)
@@ -1483,14 +1483,8 @@ FCIMPL5(void, RuntimeFieldHandle::SetValueDirect, ReflectFieldObject *pFieldUNSA
         if (gc.oValue != 0) {
             value = 0;
             if (CoreLibBinder::IsClass(gc.oValue->GetMethodTable(), CLASS__POINTER)) {
-                value = (size_t) InvokeUtil::GetPointerValue(gc.oValue);
-#ifdef _MSC_VER
-#pragma warning(disable: 4267) //work-around for compiler
-#endif
-                VolatileStore((size_t*) pDst, (size_t) value);
-#ifdef _MSC_VER
-#pragma warning(default: 4267)
-#endif
+                value = (SIZE_T) InvokeUtil::GetPointerValue(gc.oValue);
+                VolatileStore((SIZE_T*) pDst, (SIZE_T) value);
                 break;
             }
         }
@@ -1502,13 +1496,7 @@ FCIMPL5(void, RuntimeFieldHandle::SetValueDirect, ReflectFieldObject *pFieldUNSA
             CorElementType objType = gc.oValue->GetTypeHandle().GetInternalCorElementType();
             InvokeUtil::CreatePrimitiveValue(objType, objType, gc.oValue, &value);
         }
-#ifdef _MSC_VER
-#pragma warning(disable: 4267) //work-around for compiler
-#endif
-        VolatileStore((size_t*) pDst, (size_t) value);
-#ifdef _MSC_VER
-#pragma warning(default: 4267)
-#endif
+        VolatileStore((SIZE_T*) pDst, (SIZE_T) value);
     }
     break;
 
index ec1c998..6d20733 100644 (file)
@@ -1679,19 +1679,12 @@ private:
         CONSISTENCY_CHECK(index <= bucketMask()+CALL_STUB_FIRST_INDEX);
         return VolatileLoad(&buckets[index]);
     }
-
-#ifdef _MSC_VER
-#pragma warning(disable: 4267) //work-around for the compiler
-#endif
     inline void Write(size_t index, size_t value)
     {
         LIMITED_METHOD_CONTRACT;
         CONSISTENCY_CHECK(index <= bucketMask()+CALL_STUB_FIRST_INDEX);
         VolatileStore(&buckets[index], value);
     }
-#ifdef _MSC_VER
-#pragma warning(default: 4267)
-#endif
 
     // We store (#buckets-1) in    bucket[CALL_STUB_MASK_INDEX  ==0]
     // We have two unused cells at bucket[CALL_STUB_COUNT_INDEX ==1]