Merge pull request #6537 from Morph1984/warnings

general: Enforce multiple warnings in MSVC
This commit is contained in:
bunnei 2021-07-05 17:09:23 -07:00 committed by GitHub
commit bf50345d4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 27 additions and 58 deletions

View File

@ -45,13 +45,22 @@ if (MSVC)
/Zc:inline /Zc:inline
/Zc:throwingNew /Zc:throwingNew
# External headers diagnostics
/experimental:external # Enables the external headers options. This option isn't required in Visual Studio 2019 version 16.10 and later
/external:anglebrackets # Treats all headers included by #include <header>, where the header file is enclosed in angle brackets (< >), as external headers
/external:W0 # Sets the default warning level to 0 for external headers, effectively turning off warnings for external headers
# Warnings # Warnings
/W3 /W3
/we4062 # enumerator 'identifier' in a switch of enum 'enumeration' is not handled /we4018 # 'expression': signed/unsigned mismatch
/we4062 # Enumerator 'identifier' in a switch of enum 'enumeration' is not handled
/we4101 # 'identifier': unreferenced local variable /we4101 # 'identifier': unreferenced local variable
/we4189 # 'identifier': local variable is initialized but not referenced /we4189 # 'identifier': local variable is initialized but not referenced
/we4265 # 'class': class has virtual functions, but destructor is not virtual /we4265 # 'class': class has virtual functions, but destructor is not virtual
/we4388 # signed/unsigned mismatch /we4267 # 'var': conversion from 'size_t' to 'type', possible loss of data
/we4305 # 'context': truncation from 'type1' to 'type2'
/we4388 # 'expression': signed/unsigned mismatch
/we4389 # 'operator': signed/unsigned mismatch
/we4547 # 'operator': operator before comma has no effect; expected operator with side-effect /we4547 # 'operator': operator before comma has no effect; expected operator with side-effect
/we4549 # 'operator1': operator before comma has no effect; did you intend 'operator2'? /we4549 # 'operator1': operator before comma has no effect; did you intend 'operator2'?
/we4555 # Expression has no effect; expected expression with side-effect /we4555 # Expression has no effect; expected expression with side-effect

View File

@ -654,17 +654,14 @@ endif()
if (MSVC) if (MSVC)
target_compile_options(core PRIVATE target_compile_options(core PRIVATE
/we4018 # 'expression' : signed/unsigned mismatch /we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data
/we4244 # 'argument' : conversion from 'type1' to 'type2', possible loss of data (floating-point) /we4244 # 'conversion': conversion from 'type1' to 'type2', possible loss of data
/we4245 # 'conversion': conversion from 'type1' to 'type2', signed/unsigned mismatch /we4245 # 'conversion': conversion from 'type1' to 'type2', signed/unsigned mismatch
/we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data
/we4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data
/we4305 # 'context' : truncation from 'type1' to 'type2'
/we4456 # Declaration of 'identifier' hides previous local declaration /we4456 # Declaration of 'identifier' hides previous local declaration
/we4457 # Declaration of 'identifier' hides function parameter /we4457 # Declaration of 'identifier' hides function parameter
/we4458 # Declaration of 'identifier' hides class member /we4458 # Declaration of 'identifier' hides class member
/we4459 # Declaration of 'identifier' hides global declaration /we4459 # Declaration of 'identifier' hides global declaration
/we4715 # 'function' : not all control paths return a value
) )
else() else()
target_compile_options(core PRIVATE target_compile_options(core PRIVATE

View File

@ -34,18 +34,10 @@ if (MSVC)
/W4 /W4
/WX /WX
# 'expression' : signed/unsigned mismatch /we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data
/we4018 /we4244 # 'conversion': conversion from 'type1' to 'type2', possible loss of data
# 'argument' : conversion from 'type1' to 'type2', possible loss of data (floating-point) /we4245 # 'conversion': conversion from 'type1' to 'type2', signed/unsigned mismatch
/we4244 /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data
# 'conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch
/we4245
# 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data
/we4254
# 'var' : conversion from 'size_t' to 'type', possible loss of data
/we4267
# 'context' : truncation from 'type1' to 'type2'
/we4305
) )
else() else()
target_compile_options(input_common PRIVATE target_compile_options(input_common PRIVATE

View File

@ -5,14 +5,7 @@
#include <chrono> #include <chrono>
#include <thread> #include <thread>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4200) // nonstandard extension used : zero-sized array in struct/union
#endif
#include <libusb.h> #include <libusb.h>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/param_package.h" #include "common/param_package.h"

View File

@ -8,14 +8,7 @@
#include <optional> #include <optional>
#include <type_traits> #include <type_traits>
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4701)
#endif
#include <boost/crc.hpp> #include <boost/crc.hpp>
#ifdef _MSC_VER
#pragma warning(pop)
#endif
#include "common/bit_field.h" #include "common/bit_field.h"
#include "common/swap.h" #include "common/swap.h"

View File

@ -292,13 +292,12 @@ endif()
if (MSVC) if (MSVC)
target_compile_options(video_core PRIVATE target_compile_options(video_core PRIVATE
/we4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data /we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data
/we4244 # 'var' : conversion from integer to 'type', possible loss of data /we4244 # 'conversion': conversion from 'type1' to 'type2', possible loss of data
/we4456 # Declaration of 'identifier' hides previous local declaration /we4456 # Declaration of 'identifier' hides previous local declaration
/we4457 # Declaration of 'identifier' hides function parameter /we4457 # Declaration of 'identifier' hides function parameter
/we4458 # Declaration of 'identifier' hides class member /we4458 # Declaration of 'identifier' hides class member
/we4459 # Declaration of 'identifier' hides global declaration /we4459 # Declaration of 'identifier' hides global declaration
/we4715 # 'function' : not all control paths return a value
) )
else() else()
target_compile_options(video_core PRIVATE target_compile_options(video_core PRIVATE

View File

@ -14,18 +14,10 @@ extern "C" {
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wconversion"
#endif #endif
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable : 4242) // conversion from 'type' to 'type', possible loss of data
#pragma warning(disable : 4244) // conversion from 'type' to 'type', possible loss of data
#endif
#include <libavcodec/avcodec.h> #include <libavcodec/avcodec.h>
#if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif
} }
namespace Tegra { namespace Tegra {

View File

@ -9,17 +9,10 @@ extern "C" {
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion" #pragma GCC diagnostic ignored "-Wconversion"
#endif #endif
#ifdef _MSC_VER
#pragma warning(disable : 4244) // conversion from 'type' to 'type', possible loss of data
#pragma warning(push)
#endif
#include <libswscale/swscale.h> #include <libswscale/swscale.h>
#if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif #endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif
} }
#include "common/assert.h" #include "common/assert.h"

View File

@ -327,7 +327,8 @@ void ApplySwizzle(GLuint handle, PixelFormat format, std::array<SwizzleSource, 4
if (format_info.is_compressed) { if (format_info.is_compressed) {
return false; return false;
} }
if (std::ranges::find(ACCELERATED_FORMATS, internal_format) == ACCELERATED_FORMATS.end()) { if (std::ranges::find(ACCELERATED_FORMATS, static_cast<int>(internal_format)) ==
ACCELERATED_FORMATS.end()) {
return false; return false;
} }
if (format_info.compatibility_by_size) { if (format_info.compatibility_by_size) {

View File

@ -82,7 +82,7 @@ std::optional<SubresourceBase> ImageBase::TryFindBase(GPUVAddr other_addr) const
if (info.type != ImageType::e3D) { if (info.type != ImageType::e3D) {
const auto [layer, mip_offset] = LayerMipOffset(diff, info.layer_stride); const auto [layer, mip_offset] = LayerMipOffset(diff, info.layer_stride);
const auto end = mip_level_offsets.begin() + info.resources.levels; const auto end = mip_level_offsets.begin() + info.resources.levels;
const auto it = std::find(mip_level_offsets.begin(), end, mip_offset); const auto it = std::find(mip_level_offsets.begin(), end, static_cast<u32>(mip_offset));
if (layer > info.resources.layers || it == end) { if (layer > info.resources.layers || it == end) {
return std::nullopt; return std::nullopt;
} }

View File

@ -394,7 +394,7 @@ template <u32 GOB_EXTENT>
const s32 mip_offset = diff % layer_stride; const s32 mip_offset = diff % layer_stride;
const std::array offsets = CalculateMipLevelOffsets(new_info); const std::array offsets = CalculateMipLevelOffsets(new_info);
const auto end = offsets.begin() + new_info.resources.levels; const auto end = offsets.begin() + new_info.resources.levels;
const auto it = std::find(offsets.begin(), end, mip_offset); const auto it = std::find(offsets.begin(), end, static_cast<u32>(mip_offset));
if (it == end) { if (it == end) {
// Mipmap is not aligned to any valid size // Mipmap is not aligned to any valid size
return std::nullopt; return std::nullopt;

View File

@ -1365,8 +1365,8 @@ static void DecompressBlock(std::span<const u8, 16> inBuf, const u32 blockWidth,
// each partition. // each partition.
// Determine partitions, partition index, and color endpoint modes // Determine partitions, partition index, and color endpoint modes
s32 planeIdx = -1; u32 planeIdx{UINT32_MAX};
u32 partitionIndex; u32 partitionIndex{};
u32 colorEndpointMode[4] = {0, 0, 0, 0}; u32 colorEndpointMode[4] = {0, 0, 0, 0};
// Define color data. // Define color data.