Skip to content

Commit

Permalink
Remove compiler warning suppression (#66234)
Browse files Browse the repository at this point in the history
* Remove 4996

* Remove 4701

* Remove 4611

* Remove 4610

* Remove 4510

* Remove 4267

* Remove 4267 - libunwind
  • Loading branch information
AaronRobinsonMSFT authored Mar 9, 2022
1 parent 220e677 commit 853e494
Show file tree
Hide file tree
Showing 18 changed files with 19 additions and 117 deletions.
9 changes: 1 addition & 8 deletions src/coreclr/debug/daccess/daccess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions src/coreclr/jit/eeinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

/*****************************************************************************/

/*****************************************************************************
Expand Down Expand Up @@ -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)

/*****************************************************************************/
7 changes: 3 additions & 4 deletions src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include "jitpch.h"
#ifdef _MSC_VER
#pragma hdrstop
#pragma warning(disable : 4701)
#endif

/*****************************************************************************/
Expand Down Expand Up @@ -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)
{
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -5037,10 +5037,6 @@ class NativeExceptionHolderFactory

#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
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/pal/src/libunwind/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/pal/src/libunwind/include/mempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/pal/src/libunwind/libunwind-version.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions src/coreclr/pal/src/libunwind/src/dwarf/Gfind_proc_info-lsb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/pal/src/safecrt/input.inl
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down Expand Up @@ -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 */
Expand Down
10 changes: 0 additions & 10 deletions src/coreclr/pal/src/safecrt/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/tools/superpmi/superpmi-shared/standardpch.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 4 additions & 14 deletions src/coreclr/vm/codeman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
9 changes: 0 additions & 9 deletions src/coreclr/vm/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@

// 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
Expand All @@ -38,16 +35,13 @@

// 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

#pragma warning(1:4189) // local variable initialized but not used

#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

Expand All @@ -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
Expand Down
14 changes: 3 additions & 11 deletions src/coreclr/vm/eehash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/vm/fcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,6 @@
//
#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
Expand Down
9 changes: 0 additions & 9 deletions src/coreclr/vm/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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
Expand Down
18 changes: 3 additions & 15 deletions src/coreclr/vm/reflectioninvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand All @@ -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;

Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/vm/virtualcallstub.h
Original file line number Diff line number Diff line change
Expand Up @@ -1679,19 +1679,12 @@ class BucketTable
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]
Expand Down

0 comments on commit 853e494

Please sign in to comment.