From 1ae2f2a7af291d22763caab49c589fb2dd539239 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Fri, 19 Dec 2014 19:29:12 -0800 Subject: [PATCH] Fixing warnings under the new VC++. --- src/alloy/backend/ivm/ivm_intcode.cc | 38 +++++++++---------- src/alloy/backend/x64/x64_sequences.cc | 14 +++---- .../passes/dead_code_elimination_pass.cc | 2 +- src/alloy/frontend/ppc/test/alloy-ppc-test.cc | 4 +- src/poly/mapped_memory_win.cc | 2 +- src/xenia/kernel/util/xex2.cc | 16 ++++---- src/xenia/kernel/xboxkrnl_rtl.cc | 3 +- src/xenia/kernel/xboxkrnl_threading.cc | 3 +- xenia.gyp | 4 +- 9 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/alloy/backend/ivm/ivm_intcode.cc b/src/alloy/backend/ivm/ivm_intcode.cc index 7da3f960c..8c2b55d7d 100644 --- a/src/alloy/backend/ivm/ivm_intcode.cc +++ b/src/alloy/backend/ivm/ivm_intcode.cc @@ -114,7 +114,7 @@ uint32_t AllocDynamicRegister(TranslationContext& ctx, Value* value) { } else { value->flags |= VALUE_IS_ALLOCATED; auto reg = ctx.register_count++; - value->tag = reinterpret_cast(reg); + value->tag = reinterpret_cast(static_cast(reg)); return (uint32_t)reg; } } @@ -3179,8 +3179,8 @@ uint32_t IntCode_NEG_F64(IntCodeState& ics, const IntCode* i) { uint32_t IntCode_NEG_V128(IntCodeState& ics, const IntCode* i) { const vec128_t& src1 = ics.rf[i->src1_reg].v128; vec128_t& dest = ics.rf[i->dest_reg].v128; - for (size_t i = 0; i < 4; i++) { - dest.f32[i] = -src1.f32[i]; + for (size_t j = 0; j < 4; j++) { + dest.f32[j] = -src1.f32[j]; } return IA_NEXT; } @@ -3219,8 +3219,8 @@ uint32_t IntCode_ABS_F64(IntCodeState& ics, const IntCode* i) { uint32_t IntCode_ABS_V128(IntCodeState& ics, const IntCode* i) { const vec128_t& src1 = ics.rf[i->src1_reg].v128; vec128_t& dest = ics.rf[i->dest_reg].v128; - for (size_t i = 0; i < 4; i++) { - dest.f32[i] = abs(src1.f32[i]); + for (size_t j = 0; j < 4; j++) { + dest.f32[j] = abs(src1.f32[j]); } return IA_NEXT; } @@ -3275,8 +3275,8 @@ uint32_t IntCode_SQRT_F64(IntCodeState& ics, const IntCode* i) { uint32_t IntCode_SQRT_V128(IntCodeState& ics, const IntCode* i) { const vec128_t& src1 = ics.rf[i->src1_reg].v128; vec128_t& dest = ics.rf[i->dest_reg].v128; - for (size_t i = 0; i < 4; i++) { - dest.f32[i] = sqrt(src1.f32[i]); + for (size_t j = 0; j < 4; j++) { + dest.f32[j] = sqrt(src1.f32[j]); } return IA_NEXT; } @@ -3317,8 +3317,8 @@ uint32_t IntCode_POW2_F64(IntCodeState& ics, const IntCode* i) { uint32_t IntCode_POW2_V128(IntCodeState& ics, const IntCode* i) { const vec128_t& src1 = ics.rf[i->src1_reg].v128; vec128_t& dest = ics.rf[i->dest_reg].v128; - for (size_t i = 0; i < 4; i++) { - dest.f32[i] = (float)pow(2, src1.f32[i]); + for (size_t j = 0; j < 4; j++) { + dest.f32[j] = (float)pow(2, src1.f32[j]); } return IA_NEXT; } @@ -3342,8 +3342,8 @@ uint32_t IntCode_LOG2_F64(IntCodeState& ics, const IntCode* i) { uint32_t IntCode_LOG2_V128(IntCodeState& ics, const IntCode* i) { const vec128_t& src1 = ics.rf[i->src1_reg].v128; vec128_t& dest = ics.rf[i->dest_reg].v128; - for (size_t i = 0; i < 4; i++) { - dest.f32[i] = log2(src1.f32[i]); + for (size_t j = 0; j < 4; j++) { + dest.f32[j] = log2(src1.f32[j]); } return IA_NEXT; } @@ -3911,32 +3911,32 @@ int Translate_INSERT(TranslationContext& ctx, Instr* i) { uint32_t IntCode_SPLAT_V128_INT8(IntCodeState& ics, const IntCode* i) { int8_t src1 = ics.rf[i->src1_reg].i8; vec128_t& dest = ics.rf[i->dest_reg].v128; - for (size_t i = 0; i < 16; i++) { - dest.u8[i] = src1; + for (size_t j = 0; j < 16; j++) { + dest.u8[j] = src1; } return IA_NEXT; } uint32_t IntCode_SPLAT_V128_INT16(IntCodeState& ics, const IntCode* i) { int16_t src1 = ics.rf[i->src1_reg].i16; vec128_t& dest = ics.rf[i->dest_reg].v128; - for (size_t i = 0; i < 8; i++) { - dest.u16[i] = src1; + for (size_t j = 0; j < 8; j++) { + dest.u16[j] = src1; } return IA_NEXT; } uint32_t IntCode_SPLAT_V128_INT32(IntCodeState& ics, const IntCode* i) { int32_t src1 = ics.rf[i->src1_reg].i32; vec128_t& dest = ics.rf[i->dest_reg].v128; - for (size_t i = 0; i < 4; i++) { - dest.u32[i] = src1; + for (size_t j = 0; j < 4; j++) { + dest.u32[j] = src1; } return IA_NEXT; } uint32_t IntCode_SPLAT_V128_FLOAT32(IntCodeState& ics, const IntCode* i) { float src1 = ics.rf[i->src1_reg].f32; vec128_t& dest = ics.rf[i->dest_reg].v128; - for (size_t i = 0; i < 4; i++) { - dest.f32[i] = src1; + for (size_t j = 0; j < 4; j++) { + dest.f32[j] = src1; } return IA_NEXT; } diff --git a/src/alloy/backend/x64/x64_sequences.cc b/src/alloy/backend/x64/x64_sequences.cc index f11d26d7e..fcc4649d9 100644 --- a/src/alloy/backend/x64/x64_sequences.cc +++ b/src/alloy/backend/x64/x64_sequences.cc @@ -1548,7 +1548,7 @@ EMITTER(STORE_I8, MATCH(I, I8<>>)) { e.mov(e.byte[addr], i.src2); } if (IsTracingData()) { - auto addr = ComputeMemoryAddress(e, i.src1); + addr = ComputeMemoryAddress(e, i.src1); e.mov(e.r8b, e.byte[addr]); e.lea(e.rdx, e.ptr[addr]); e.CallNative(reinterpret_cast(TraceMemoryStoreI8)); @@ -1564,7 +1564,7 @@ EMITTER(STORE_I16, MATCH(I, I16<>>)) { e.mov(e.word[addr], i.src2); } if (IsTracingData()) { - auto addr = ComputeMemoryAddress(e, i.src1); + addr = ComputeMemoryAddress(e, i.src1); e.mov(e.r8w, e.word[addr]); e.lea(e.rdx, e.ptr[addr]); e.CallNative(reinterpret_cast(TraceMemoryStoreI16)); @@ -1580,7 +1580,7 @@ EMITTER(STORE_I32, MATCH(I, I32<>>)) { e.mov(e.dword[addr], i.src2); } if (IsTracingData()) { - auto addr = ComputeMemoryAddress(e, i.src1); + addr = ComputeMemoryAddress(e, i.src1); e.mov(e.r8d, e.dword[addr]); e.lea(e.rdx, e.ptr[addr]); e.CallNative(reinterpret_cast(TraceMemoryStoreI32)); @@ -1596,7 +1596,7 @@ EMITTER(STORE_I64, MATCH(I, I64<>>)) { e.mov(e.qword[addr], i.src2); } if (IsTracingData()) { - auto addr = ComputeMemoryAddress(e, i.src1); + addr = ComputeMemoryAddress(e, i.src1); e.mov(e.r8, e.qword[addr]); e.lea(e.rdx, e.ptr[addr]); e.CallNative(reinterpret_cast(TraceMemoryStoreI64)); @@ -1612,7 +1612,7 @@ EMITTER(STORE_F32, MATCH(I, F32<>>)) { e.vmovss(e.dword[addr], i.src2); } if (IsTracingData()) { - auto addr = ComputeMemoryAddress(e, i.src1); + addr = ComputeMemoryAddress(e, i.src1); e.lea(e.r8, e.ptr[addr]); e.lea(e.rdx, e.ptr[addr]); e.CallNative(reinterpret_cast(TraceMemoryStoreF32)); @@ -1628,7 +1628,7 @@ EMITTER(STORE_F64, MATCH(I, F64<>>)) { e.vmovsd(e.qword[addr], i.src2); } if (IsTracingData()) { - auto addr = ComputeMemoryAddress(e, i.src1); + addr = ComputeMemoryAddress(e, i.src1); e.lea(e.r8, e.ptr[addr]); e.lea(e.rdx, e.ptr[addr]); e.CallNative(reinterpret_cast(TraceMemoryStoreF64)); @@ -1645,7 +1645,7 @@ EMITTER(STORE_V128, MATCH(I, V128<>>)) { e.vmovaps(e.ptr[addr], i.src2); } if (IsTracingData()) { - auto addr = ComputeMemoryAddress(e, i.src1); + addr = ComputeMemoryAddress(e, i.src1); e.lea(e.r8, e.ptr[addr]); e.lea(e.rdx, e.ptr[addr]); e.CallNative(reinterpret_cast(TraceMemoryStoreV128)); diff --git a/src/alloy/compiler/passes/dead_code_elimination_pass.cc b/src/alloy/compiler/passes/dead_code_elimination_pass.cc index 6ff73609e..b439edad3 100644 --- a/src/alloy/compiler/passes/dead_code_elimination_pass.cc +++ b/src/alloy/compiler/passes/dead_code_elimination_pass.cc @@ -114,7 +114,7 @@ int DeadCodeEliminationPass::Run(HIRBuilder* builder) { // Remove all nops. if (any_instr_removed) { - auto block = builder->first_block(); + block = builder->first_block(); while (block) { Instr* i = block->instr_head; while (i) { diff --git a/src/alloy/frontend/ppc/test/alloy-ppc-test.cc b/src/alloy/frontend/ppc/test/alloy-ppc-test.cc index a19e5c850..4970325e8 100644 --- a/src/alloy/frontend/ppc/test/alloy-ppc-test.cc +++ b/src/alloy/frontend/ppc/test/alloy-ppc-test.cc @@ -421,9 +421,9 @@ bool RunTests(const std::wstring& test_name) { int failed_count = 0; int passed_count = 0; - auto test_path = poly::fix_path_separators(poly::to_wstring(FLAGS_test_path)); + auto test_path_root = poly::fix_path_separators(poly::to_wstring(FLAGS_test_path)); std::vector test_files; - if (!DiscoverTests(test_path, test_files)) { + if (!DiscoverTests(test_path_root, test_files)) { return false; } if (!test_files.size()) { diff --git a/src/poly/mapped_memory_win.cc b/src/poly/mapped_memory_win.cc index 8e5b523d6..e40f2144d 100644 --- a/src/poly/mapped_memory_win.cc +++ b/src/poly/mapped_memory_win.cc @@ -65,7 +65,7 @@ std::unique_ptr MappedMemory::Open(const std::wstring& path, GetSystemInfo(&systemInfo); const size_t aligned_offset = - offset & (~(systemInfo.dwAllocationGranularity - 1)); + offset & ~static_cast(systemInfo.dwAllocationGranularity - 1); const size_t aligned_length = length + (offset - aligned_offset); auto mm = std::make_unique(path, mode); diff --git a/src/xenia/kernel/util/xex2.cc b/src/xenia/kernel/util/xex2.cc index 979706a82..8e2e67db5 100644 --- a/src/xenia/kernel/util/xex2.cc +++ b/src/xenia/kernel/util/xex2.cc @@ -164,13 +164,13 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, header->resource_info_count = (opt_header->length - 4) / 16; header->resource_infos = (xe_xex2_resource_info_t *)calloc( header->resource_info_count, sizeof(xe_xex2_resource_info_t)); - const uint8_t *ph = pp + 0x04; - for (size_t n = 0; n < header->resource_info_count; n++) { - auto &res = header->resource_infos[n]; - memcpy(res.name, ph + 0x00, 8); - res.address = poly::load_and_swap(ph + 0x08); - res.size = poly::load_and_swap(ph + 0x0C); - ph += 16; + const uint8_t *phi = pp + 0x04; + for (size_t m = 0; m < header->resource_info_count; m++) { + auto &res = header->resource_infos[m]; + memcpy(res.name, phi + 0x00, 8); + res.address = poly::load_and_swap(phi + 0x08); + res.size = poly::load_and_swap(phi + 0x0C); + phi += 16; } } break; case XEX_HEADER_EXECUTION_INFO: { @@ -609,7 +609,7 @@ int xe_xex2_read_image_basic_compressed(const xe_xex2_header_t *header, case XEX_ENCRYPTION_NORMAL: { const uint8_t *ct = p; uint8_t *pt = d; - for (size_t n = 0; n < data_size; n += 16, ct += 16, pt += 16) { + for (size_t m = 0; m < data_size; m += 16, ct += 16, pt += 16) { // Decrypt 16 uint8_ts from input -> output. rijndaelDecrypt(rk, Nr, ct, pt); for (size_t i = 0; i < 16; i++) { diff --git a/src/xenia/kernel/xboxkrnl_rtl.cc b/src/xenia/kernel/xboxkrnl_rtl.cc index e1e1ea7a2..8a58f39b0 100644 --- a/src/xenia/kernel/xboxkrnl_rtl.cc +++ b/src/xenia/kernel/xboxkrnl_rtl.cc @@ -129,7 +129,7 @@ SHIM_CALL RtlInitAnsiString_shim(PPCContext* ppc_state, KernelState* state) { uint32_t destination_ptr = SHIM_GET_ARG_32(0); uint32_t source_ptr = SHIM_GET_ARG_32(1); - const char* source = source_ptr ? (char*)SHIM_MEM_ADDR(source_ptr) : NULL; + const char* source = source_ptr ? (char*)SHIM_MEM_ADDR(source_ptr) : nullptr; XELOGD("RtlInitAnsiString(%.8X, %.8X = %s)", destination_ptr, source_ptr, source ? source : ""); @@ -138,7 +138,6 @@ SHIM_CALL RtlInitAnsiString_shim(PPCContext* ppc_state, KernelState* state) { // _In_opt_ PCSZ SourceString if (source_ptr != 0) { - const char* source = (char*)SHIM_MEM_ADDR(source_ptr); uint16_t length = (uint16_t)strlen(source); SHIM_SET_MEM_16(destination_ptr + 0, length); SHIM_SET_MEM_16(destination_ptr + 2, length + 1); diff --git a/src/xenia/kernel/xboxkrnl_threading.cc b/src/xenia/kernel/xboxkrnl_threading.cc index a727d8f45..4a9be33ec 100644 --- a/src/xenia/kernel/xboxkrnl_threading.cc +++ b/src/xenia/kernel/xboxkrnl_threading.cc @@ -390,7 +390,8 @@ SHIM_CALL KeTlsSetValue_shim(PPCContext* ppc_state, KernelState* state) { int result = 0; #if XE_PLATFORM_WIN32 - result = TlsSetValue(tls_index, (LPVOID)tls_value); + result = TlsSetValue( + tls_index, reinterpret_cast(static_cast(tls_value))); #else result = pthread_setspecific(tls_index, (void*)tls_value) == 0; #endif // WIN32 diff --git a/xenia.gyp b/xenia.gyp index 5534d7534..2c64376d8 100644 --- a/xenia.gyp +++ b/xenia.gyp @@ -76,7 +76,9 @@ 'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)', 'CharacterSet': '1', }, - 'msvs_disabled_warnings': [], + 'msvs_disabled_warnings': [ + 4458, # warning C4458: declaration of 'x' hides class member + ], 'msvs_configuration_platform': 'x64', 'msvs_cygwin_shell': '0', 'msvs_settings': {