From 69bdfaaa14b719ee95e4ebd1270084c5a2bd2f32 Mon Sep 17 00:00:00 2001 From: Adeel Mujahid <3840695+am11@users.noreply.github.com> Date: Sun, 22 Aug 2021 13:53:43 +0300 Subject: [PATCH] Fix a few gcc warnings in jit (#57744) --- src/coreclr/jit/CMakeLists.txt | 3 +-- src/coreclr/jit/bitsetasshortlong.h | 4 ++-- src/coreclr/jit/codegenxarch.cpp | 4 ++-- src/coreclr/jit/emitarm.cpp | 2 +- src/coreclr/jit/emitxarch.cpp | 4 ++-- src/coreclr/jit/gcencode.cpp | 2 +- src/coreclr/jit/inlinepolicy.h | 2 +- src/coreclr/jit/lir.h | 2 +- src/coreclr/jit/morph.cpp | 2 +- 9 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index 9ec0dcd0d1803..67c6e561ae785 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -4,8 +4,7 @@ include_directories("./jitstd") include_directories("../inc") if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - add_compile_options($<$:-fpermissive>) - add_compile_options(-Wno-error) + add_compile_options(-Wno-error) # tracked by https://github.com/dotnet/runtime/issues/33541 endif() function(create_standalone_jit) diff --git a/src/coreclr/jit/bitsetasshortlong.h b/src/coreclr/jit/bitsetasshortlong.h index dce54d6a5ca3a..d343edeeda4cd 100644 --- a/src/coreclr/jit/bitsetasshortlong.h +++ b/src/coreclr/jit/bitsetasshortlong.h @@ -345,7 +345,7 @@ class BitSetOpsgsGlobalSecurityCookieVal != 0); #ifdef TARGET_AMD64 - if ((int)compiler->gsGlobalSecurityCookieVal != compiler->gsGlobalSecurityCookieVal) + if ((size_t)(int)compiler->gsGlobalSecurityCookieVal != compiler->gsGlobalSecurityCookieVal) { // initReg = #GlobalSecurityCookieVal64; [frame.GSSecurityCookie] = initReg genSetRegToIcon(initReg, compiler->gsGlobalSecurityCookieVal, TYP_I_IMPL); @@ -2511,7 +2511,7 @@ void CodeGen::genLclHeap(GenTree* tree) amount /= STACK_ALIGN; } - genSetRegToIcon(regCnt, amount, ((int)amount == amount) ? TYP_INT : TYP_LONG); + genSetRegToIcon(regCnt, amount, ((size_t)(int)amount == amount) ? TYP_INT : TYP_LONG); } if (compiler->info.compInitMem) diff --git a/src/coreclr/jit/emitarm.cpp b/src/coreclr/jit/emitarm.cpp index b8a730a31a748..8e3257ce40e63 100644 --- a/src/coreclr/jit/emitarm.cpp +++ b/src/coreclr/jit/emitarm.cpp @@ -6790,7 +6790,7 @@ void emitter::emitDispImm(int imm, bool addComma, bool alwaysHex /* =false */) printf("%d", imm); else if ((imm > 0) || (imm == -imm) || // -0x80000000 == 0x80000000. So we don't want to add an extra "-" at the beginning. - (emitComp->opts.disDiffable && (imm == 0xD1FFAB1E))) // Don't display this as negative + (emitComp->opts.disDiffable && (imm == (int)0xD1FFAB1E))) // Don't display this as negative printf("0x%02x", imm); else // val <= -1000 printf("-0x%02x", -imm); diff --git a/src/coreclr/jit/emitxarch.cpp b/src/coreclr/jit/emitxarch.cpp index 16ad448cd3d76..1e0660b24cb7c 100644 --- a/src/coreclr/jit/emitxarch.cpp +++ b/src/coreclr/jit/emitxarch.cpp @@ -7624,7 +7624,7 @@ void emitter::emitIns_Call(EmitCallType callType, // An absolute indir address that doesn't need reloc should fit within 32-bits // to be encoded as offset relative to zero. This addr mode requires an extra // SIB byte - noway_assert(static_cast(reinterpret_cast(addr)) == (size_t)addr); + noway_assert((size_t) static_cast(reinterpret_cast(addr)) == (size_t)addr); sz++; } #endif // TARGET_AMD64 @@ -7660,7 +7660,7 @@ void emitter::emitIns_Call(EmitCallType callType, // An absolute indir address that doesn't need reloc should fit within 32-bits // to be encoded as offset relative to zero. This addr mode requires an extra // SIB byte - noway_assert(static_cast(reinterpret_cast(addr)) == (size_t)addr); + noway_assert((size_t) static_cast(reinterpret_cast(addr)) == (size_t)addr); sz++; } #endif // TARGET_AMD64 diff --git a/src/coreclr/jit/gcencode.cpp b/src/coreclr/jit/gcencode.cpp index 60011aade5499..4719b4a6e3521 100644 --- a/src/coreclr/jit/gcencode.cpp +++ b/src/coreclr/jit/gcencode.cpp @@ -1672,7 +1672,7 @@ size_t GCInfo::gcInfoBlockHdrSave( #if REGEN_SHORTCUTS regenLog(headerEncoding, header, &state); #endif - _ASSERTE(codeSet == 1 || codeSet == 2 && "Encoding must correspond to InfoHdrAdjust or InfoHdrAdjust2"); + _ASSERTE((codeSet == 1 || codeSet == 2) && "Encoding must correspond to InfoHdrAdjust or InfoHdrAdjust2"); if (codeSet == 2) { *dest++ = NEXT_OPCODE | MORE_BYTES_TO_FOLLOW; diff --git a/src/coreclr/jit/inlinepolicy.h b/src/coreclr/jit/inlinepolicy.h index 466e17fe0e112..e604fd57a36ed 100644 --- a/src/coreclr/jit/inlinepolicy.h +++ b/src/coreclr/jit/inlinepolicy.h @@ -185,7 +185,7 @@ class DefaultPolicy : public LegalPolicy class ExtendedDefaultPolicy : public DefaultPolicy { public: - ExtendedDefaultPolicy::ExtendedDefaultPolicy(Compiler* compiler, bool isPrejitRoot) + ExtendedDefaultPolicy(Compiler* compiler, bool isPrejitRoot) : DefaultPolicy(compiler, isPrejitRoot) , m_ProfileFrequency(0.0) , m_BinaryExprWithCns(0) diff --git a/src/coreclr/jit/lir.h b/src/coreclr/jit/lir.h index f205527df5c71..b52f1cb63c8f2 100644 --- a/src/coreclr/jit/lir.h +++ b/src/coreclr/jit/lir.h @@ -298,7 +298,7 @@ class LIR final public: static Range& AsRange(BasicBlock* block); - static const LIR::Range& LIR::AsRange(const BasicBlock* block); + static const Range& AsRange(const BasicBlock* block); static Range EmptyRange(); static Range SeqTree(Compiler* compiler, GenTree* tree); diff --git a/src/coreclr/jit/morph.cpp b/src/coreclr/jit/morph.cpp index 6ccd989dea79d..fb06c52b0942c 100644 --- a/src/coreclr/jit/morph.cpp +++ b/src/coreclr/jit/morph.cpp @@ -3394,7 +3394,7 @@ void Compiler::fgInitArgInfo(GenTreeCall* call) if (callIsVararg) { // Override the decision and force a split. - isRegArg = isRegArg = (intArgRegNum + (size - 1)) <= maxRegArgs; + isRegArg = (intArgRegNum + (size - 1)) <= maxRegArgs; } else #endif // defined(TARGET_WINDOWS)