From cb3773542726fda1267e81596bd37654f418cff4 Mon Sep 17 00:00:00 2001 From: Jan Vorlicek Date: Sat, 31 Jan 2015 01:26:55 -0800 Subject: [PATCH] Replaced compiler option to disabled all warnings in Linux build by options for explicit disabling of specific warnings. Fixed warnings that were not possible to disable (those that have no identifier) and few other trivial ones. We will need to revisit the warnings fix as many as we reasonably can. [tfs-changeset: 1408205] --- CMakeLists.txt | 42 ++++++++++++++++++++++++++--- src/debug/ee/debugger.cpp | 2 +- src/gc/gc.cpp | 16 +++++------ src/inc/arraylist.h | 2 +- src/inc/complex.h | 2 +- src/md/enc/metamodelrw.cpp | 2 +- src/pal/inc/pal.h | 3 +-- src/pal/inc/pal_char16.h | 2 ++ src/vm/amd64/unixstubs.cpp | 4 +-- src/vm/amd64/virtualcallstubcpu.hpp | 2 +- src/vm/corhost.cpp | 2 +- src/vm/exceptionhandling.cpp | 4 ++- src/vm/gcstress.h | 6 ++--- src/vm/methodtable.cpp | 7 +---- src/vm/multicorejit.cpp | 7 ----- src/vm/syncblk.cpp | 4 +-- src/vm/threadsuspend.cpp | 6 ++--- 17 files changed, 69 insertions(+), 44 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e7e944652d86..c7f55e693ee9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -203,10 +203,44 @@ add_definitions(-DDISABLE_CONTRACTS) # The -ferror-limit is helpful during the porting, it makes sure the compiler doesn't stop # after hitting just about 20 errors. add_compile_options(-ferror-limit=4096) -# The -w option disables warnings for now, there are hundreds of them and it is hard to -# find the errors in the output. We need to reenable them later though to make sure we don't` -# miss any real issues. -add_compile_options(-w) + +# Disabled warnings +add_compile_options(-Wno-reorder) +add_compile_options(-Wno-ignored-attributes) +add_compile_options(-Wno-unknown-pragmas) +add_compile_options(-Wno-unused-private-field) +add_compile_options(-Wno-new-returns-null) +add_compile_options(-Wno-dangling-else) +add_compile_options(-Wno-implicit-exception-spec-mismatch) +add_compile_options(-Wno-deprecated-register) +add_compile_options(-Wno-parentheses) +add_compile_options(-Wno-overloaded-virtual) +add_compile_options(-Wno-unused-variable) +add_compile_options(-Wno-missing-declarations) +add_compile_options(-Wno-switch) +add_compile_options(-Wno-extern-initializer) +add_compile_options(-Wno-microsoft) +add_compile_options(-Wno-mismatched-tags) +add_compile_options(-Wno-ignored-qualifiers) +add_compile_options(-Wno-tautological-constant-out-of-range-compare) +add_compile_options(-Wno-c++11-compat-deprecated-writable-strings) +add_compile_options(-Wno-unneeded-internal-declaration) +add_compile_options(-Wno-tautological-compare) +add_compile_options(-Wno-constant-logical-operand) +add_compile_options(-Wno-unused-function) +add_compile_options(-Wno-extra-tokens) +add_compile_options(-Wno-self-assign) +add_compile_options(-Wno-bitfield-constant-conversion) +add_compile_options(-Wno-unused-value) + +#These seem to indicate real issues +add_compile_options(-Wno-invalid-offsetof) +add_compile_options(-Wno-return-type) +add_compile_options(-Wno-dynamic-class-memaccess) +add_compile_options(-Wno-int-to-pointer-cast) +add_compile_options(-Wno-delete-non-virtual-dtor) +add_compile_options(-Wno-enum-compare) + # The -fms-extensions enable the stuff like __if_exists, __declspec(uuid()), etc. add_compile_options(-fms-extensions ) #-fms-compatibility Enable full Microsoft Visual C++ compatibility diff --git a/src/debug/ee/debugger.cpp b/src/debug/ee/debugger.cpp index 5b961a2b7e6c..723c662b18ba 100644 --- a/src/debug/ee/debugger.cpp +++ b/src/debug/ee/debugger.cpp @@ -10765,7 +10765,7 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent) // If we need to fault, let's generate an access violation. if (s_fDbgFaultInHandleIPCEvent) { - *((BYTE *)0) = 0; + *((volatile BYTE *)0) = 0; } #endif diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp index e0cd018cfe85..e063491fbbbf 100644 --- a/src/gc/gc.cpp +++ b/src/gc/gc.cpp @@ -5796,7 +5796,7 @@ inline BOOL grow_mark_stack (mark*& m, size_t& len, size_t init_len) { size_t new_size = max (init_len, 2*len); - mark* tmp = new (nothrow) (mark [new_size]); + mark* tmp = new (nothrow) mark [new_size]; if (tmp) { memcpy (tmp, m, len * sizeof (mark)); @@ -8125,7 +8125,7 @@ class seg_free_spaces MAX_NUM_BUCKETS * sizeof (free_space_bucket) + MAX_NUM_FREE_SPACES * sizeof (seg_free_space); - free_space_buckets = (free_space_bucket*) new (nothrow) (BYTE[total_prealloc_size]); + free_space_buckets = (free_space_bucket*) new (nothrow) BYTE[total_prealloc_size]; return (!!free_space_buckets); } @@ -16810,7 +16810,7 @@ gc_heap::ha_mark_object_simple (BYTE** po THREAD_NUMBER_DCL) { if (!internal_root_array) { - internal_root_array = new (nothrow) (BYTE* [internal_root_array_length]); + internal_root_array = new (nothrow) BYTE* [internal_root_array_length]; if (!internal_root_array) { heap_analyze_success = FALSE; @@ -16829,7 +16829,7 @@ gc_heap::ha_mark_object_simple (BYTE** po THREAD_NUMBER_DCL) } else { - BYTE** tmp = new (nothrow) (BYTE* [new_size]); + BYTE** tmp = new (nothrow) BYTE* [new_size]; if (tmp) { memcpy (tmp, internal_root_array, @@ -17715,7 +17715,7 @@ BOOL gc_heap::background_process_mark_overflow (BOOL concurrent_p) { dprintf (2, ("h%d: ov grow to %Id", heap_number, new_size)); - BYTE** tmp = new (nothrow) (BYTE* [new_size]); + BYTE** tmp = new (nothrow) BYTE* [new_size]; if (tmp) { delete background_mark_stack_array; @@ -17821,7 +17821,7 @@ BOOL gc_heap::process_mark_overflow(int condemned_gen_number) if ((mark_stack_array_length < new_size) && ((new_size - mark_stack_array_length) > (mark_stack_array_length / 2))) { - mark* tmp = new (nothrow) (mark [new_size]); + mark* tmp = new (nothrow) mark [new_size]; if (tmp) { delete mark_stack_array; @@ -25135,7 +25135,7 @@ void gc_heap::background_grow_c_mark_list() } else { - new_c_mark_list = new (nothrow) (BYTE*[c_mark_list_length*2]); + new_c_mark_list = new (nothrow) BYTE*[c_mark_list_length*2]; if (new_c_mark_list == 0) { should_drain_p = TRUE; @@ -35084,7 +35084,7 @@ CFinalize::GrowArray() size_t oldArraySize = (m_EndArray - m_Array); size_t newArraySize = (size_t)(((float)oldArraySize / 10) * 12); - Object** newArray = new (nothrow)(Object*[newArraySize]); + Object** newArray = new (nothrow) Object*[newArraySize]; if (!newArray) { // It's not safe to throw here, because of the FinalizeLock. Tell our caller diff --git a/src/inc/arraylist.h b/src/inc/arraylist.h index 907fc5f9e402..f6f4014c4e69 100644 --- a/src/inc/arraylist.h +++ b/src/inc/arraylist.h @@ -496,7 +496,7 @@ class StructArrayList : public StructArrayListBase class ItemIterator { - typedef typename StructArrayList + typedef StructArrayList SAList; typedef typename StructArrayList::ArrayIterator diff --git a/src/inc/complex.h b/src/inc/complex.h index e2cbeb6ad412..82a39fea3a2f 100644 --- a/src/inc/complex.h +++ b/src/inc/complex.h @@ -32,7 +32,7 @@ class Complex double r; double i; - Complex() : r(0), i(i) {} + Complex() : r(0), i(0) {} Complex(double real) : r(real), i(0) {} Complex(double real, double imag) : r(real), i(imag) {} Complex(const Complex& other) : r(other.r), i(other.i) {} diff --git a/src/md/enc/metamodelrw.cpp b/src/md/enc/metamodelrw.cpp index 70b8e72a444f..1575ebfaa111 100644 --- a/src/md/enc/metamodelrw.cpp +++ b/src/md/enc/metamodelrw.cpp @@ -3511,7 +3511,7 @@ CMiniMdRW::SaveFullTablesToStream( // For each table... for (ixTbl=0; ixTblAddFiberInfo(Thread::ThreadTrackInfo_Lifetime); #endif #ifdef STRESS_LOG - if (StressLog::StressLogOn(~0ul, 0)) + if (StressLog::StressLogOn(~0u, 0)) { StressLog::CreateThreadStressLog(); } diff --git a/src/vm/exceptionhandling.cpp b/src/vm/exceptionhandling.cpp index f984f94379c7..36dca5ee1259 100644 --- a/src/vm/exceptionhandling.cpp +++ b/src/vm/exceptionhandling.cpp @@ -106,7 +106,7 @@ static ExceptionTracker* GetTrackerMemory() return g_theTrackerAllocator.GetTrackerMemory(); } -static void FreeTrackerMemory(ExceptionTracker* pTracker, TrackerMemoryType mem) +void FreeTrackerMemory(ExceptionTracker* pTracker, TrackerMemoryType mem) { CONTRACTL { @@ -380,8 +380,10 @@ void ExceptionTracker::UpdateNonvolatileRegisters(CONTEXT *pContextRecord, REGDI UPDATEREG(Rbx); UPDATEREG(Rbp); +#ifndef UNIX_AMD64_ABI UPDATEREG(Rsi); UPDATEREG(Rdi); +#endif UPDATEREG(R12); UPDATEREG(R13); UPDATEREG(R14); diff --git a/src/vm/gcstress.h b/src/vm/gcstress.h index adc02d7470df..cda7e13b5072 100644 --- a/src/vm/gcstress.h +++ b/src/vm/gcstress.h @@ -188,10 +188,10 @@ namespace _GCStress { // no definition provided so that absence of concrete implementations cause compiler errors template - static bool IsEnabled(); + bool IsEnabled(); template<> FORCEINLINE - static bool IsEnabled() + bool IsEnabled() { // Most correct would be to test for each specific bits, but we've // always only tested against 0... @@ -203,7 +203,7 @@ namespace _GCStress #define DefineIsEnabled(cfg_enum, eeconfig_bits) \ template<> FORCEINLINE \ - static bool IsEnabled() \ + bool IsEnabled() \ { \ return (g_pConfig->GetGCStressLevel() & (eeconfig_bits)) != 0; \ } diff --git a/src/vm/methodtable.cpp b/src/vm/methodtable.cpp index 35db4ac65124..781b946e6d6f 100644 --- a/src/vm/methodtable.cpp +++ b/src/vm/methodtable.cpp @@ -4451,9 +4451,6 @@ VOID DoAccessibilityCheckForConstraints(MethodTable *pAskingMT, TypeVarTypeDesc // walked. Note that it would be just as correct to always defer to the pending list - // however, that is a little less performant. // -// pInstContext - instantiation context created in code:SigPointer.GetTypeHandleThrowing and -// ultimately passed down to code:TypeVarTypeDesc.SatisfiesConstraints. -// // Closure of locals necessary for implementing CheckForEquivalenceAndFullyLoadType. @@ -4463,7 +4460,6 @@ struct DoFullyLoadLocals DoFullyLoadLocals(DFLPendingList *pPendingParam, ClassLoadLevel levelParam, MethodTable *pMT, Generics::RecursionGraph *pVisited) : newVisited(pVisited, TypeHandle(pMT)), pPending(pPendingParam), - pInstContext(pInstContext), level(levelParam), fBailed(FALSE) #ifdef FEATURE_COMINTEROP @@ -4477,7 +4473,6 @@ struct DoFullyLoadLocals Generics::RecursionGraph newVisited; DFLPendingList * const pPending; - const InstantiationContext * const pInstContext; const ClassLoadLevel level; BOOL fBailed; #ifdef FEATURE_COMINTEROP @@ -4507,7 +4502,7 @@ static void CheckForEquivalenceAndFullyLoadType(Module *pModule, mdToken token, TypeHandle th = sigPtr.GetTypeHandleThrowing(pModule, pTypeContext, ClassLoader::LoadTypes, (ClassLoadLevel)(pLocals->level - 1)); CONSISTENCY_CHECK(!th.IsNull()); - th.DoFullyLoad(&pLocals->newVisited, pLocals->level, pLocals->pPending, &pLocals->fBailed, pLocals->pInstContext); + th.DoFullyLoad(&pLocals->newVisited, pLocals->level, pLocals->pPending, &pLocals->fBailed, NULL); pLocals->fDependsOnEquivalentOrForwardedStructs = TRUE; pLocals->fHasEquivalentStructParameter = TRUE; } diff --git a/src/vm/multicorejit.cpp b/src/vm/multicorejit.cpp index 8517f1d2d299..8ba943108cb2 100644 --- a/src/vm/multicorejit.cpp +++ b/src/vm/multicorejit.cpp @@ -78,13 +78,6 @@ bool MulticoreJitManager::IsLoadOkay(Module * pModule) #endif -// #define MCGEN_ENABLE_CHECK(Context, Descriptor) (Context.IsEnabled && McGenEventTracingEnabled(&Context, &Descriptor)) - -// #define FireEtwMulticoreJit(ClrInstanceID, String1, String2, Int1, Int2, Int3)\ -// MCGEN_ENABLE_CHECK(MICROSOFT_WINDOWS_DOTNETRUNTIME_PRIVATE_PROVIDER_Context, MulticoreJit) ?\ -// CoMofTemplate_hzzddd(Microsoft_Windows_DotNETRuntimePrivateHandle, &MulticoreJit, &CLRMulticoreJitId, ClrInstanceID, String1, String2, Int1, Int2, Int3)\ -// : ERROR_SUCCESS\ - void MulticoreJitFireEtw(const wchar_t * pAction, const wchar_t * pTarget, int p1, int p2, int p3) { LIMITED_METHOD_CONTRACT diff --git a/src/vm/syncblk.cpp b/src/vm/syncblk.cpp index a0e7b0daa235..83e4f4eb27cf 100644 --- a/src/vm/syncblk.cpp +++ b/src/vm/syncblk.cpp @@ -1129,8 +1129,8 @@ void SyncBlockCache::Grow() COMPlusThrowOM(); } - newSyncTable = new(SyncTableEntry[newSyncTableSize]); - newBitMap = new(DWORD[BitMapSize (newSyncTableSize)]); + newSyncTable = new SyncTableEntry[newSyncTableSize]; + newBitMap = new DWORD[BitMapSize (newSyncTableSize)]; { diff --git a/src/vm/threadsuspend.cpp b/src/vm/threadsuspend.cpp index 46e9e65c5e08..98800f6e85da 100644 --- a/src/vm/threadsuspend.cpp +++ b/src/vm/threadsuspend.cpp @@ -1098,7 +1098,7 @@ BOOL Thread::IsExecutingWithinCer() pThread->StackWalkFrames(TAStackCrawlCallBack, &sContext); #ifdef STRESS_LOG - if (sContext.fWithinCer && StressLog::StressLogOn(~0ul, 0)) + if (sContext.fWithinCer && StressLog::StressLogOn(~0u, 0)) { // If stress log is on, write info to stress log StackCrawlContext sContext1 = { pThread, @@ -1459,7 +1459,7 @@ BOOL Thread::ReadyForAsyncException(ThreadInterruptMode mode) #ifdef STRESS_LOG REGDISPLAY rd1; - if (StressLog::StressLogOn(~0ul, 0)) + if (StressLog::StressLogOn(~0u, 0)) { CONTEXT ctx1; CopyRegDisplay(&rd, &rd1, &ctx1); @@ -1494,7 +1494,7 @@ BOOL Thread::ReadyForAsyncException(ThreadInterruptMode mode) } #ifdef STRESS_LOG - if (StressLog::StressLogOn(~0ul, 0) && + if (StressLog::StressLogOn(~0u, 0) && (IsRudeAbort() || !TAContext.fWithinEHClause)) { //Save into stresslog.