src/CMakeLists: Enforce multiple warnings on MSVC (#5692)

This commit is contained in:
Tobias 2022-11-09 23:14:28 +01:00 committed by GitHub
parent 38b8bf12de
commit bb05d8c12a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 53 additions and 30 deletions

View file

@ -46,7 +46,16 @@ if (MSVC)
# Warnings
/W3
/we4062 # enumerator 'identifier' in a switch of enum 'enumeration' is not handled
/we4101 # 'identifier': unreferenced local variable
/we4265 # 'class': class has virtual functions, but destructor is not virtual
/we4267 # 'var': conversion from 'size_t' to 'type', possible loss of data
/we4388 # signed/unsigned mismatch
/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'?
/we4555 # Expression has no effect; expected expression with side-effect
/we4834 # Discarding return value of function with 'nodiscard' attribute
/we5038 # data member 'member1' will be initialized after data member 'member2'
)
else()
add_compile_options(
@ -64,7 +73,16 @@ if (MSVC)
# Warnings
/W3
/we4062 # enumerator 'identifier' in a switch of enum 'enumeration' is not handled
/we4101 # 'identifier': unreferenced local variable
/we4265 # 'class': class has virtual functions, but destructor is not virtual
/we4267 # 'var': conversion from 'size_t' to 'type', possible loss of data
/we4388 # signed/unsigned mismatch
/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'?
/we4555 # Expression has no effect; expected expression with side-effect
/we4834 # Discarding return value of function with 'nodiscard' attribute
/we5038 # data member 'member1' will be initialized after data member 'member2'
)
endif()

View file

@ -139,7 +139,8 @@ static void OnNetworkError(const Network::RoomMember::Error& error) {
LOG_ERROR(Network, "You have been banned by the host");
break;
default:
LOG_ERROR(Network, "Unknown network error {}", error);
LOG_ERROR(Network, "Unknown network error: {}", error);
break;
}
}

View file

@ -138,7 +138,7 @@ public:
// Only implemented for T=float
[[nodiscard]] float Length() const;
[[nodiscard]] float Normalize(); // returns the previous length, which is often useful
float Normalize(); // returns the previous length, which is often useful
[[nodiscard]] constexpr T& operator[](std::size_t i) {
return *((&x) + i);
@ -314,7 +314,7 @@ public:
// Only implemented for T=float
[[nodiscard]] float Length() const;
[[nodiscard]] Vec3 Normalized() const;
[[nodiscard]] float Normalize(); // returns the previous length, which is often useful
float Normalize(); // returns the previous length, which is often useful
[[nodiscard]] constexpr T& operator[](std::size_t i) {
return *((&x) + i);

View file

@ -45,7 +45,7 @@ void CheatEngine::AddCheat(const std::shared_ptr<CheatBase>& cheat) {
cheats_list.push_back(cheat);
}
void CheatEngine::RemoveCheat(int index) {
void CheatEngine::RemoveCheat(std::size_t index) {
std::unique_lock<std::shared_mutex> lock(cheats_list_mutex);
if (index < 0 || index >= static_cast<int>(cheats_list.size())) {
LOG_ERROR(Core_Cheats, "Invalid index {}", index);
@ -54,7 +54,7 @@ void CheatEngine::RemoveCheat(int index) {
cheats_list.erase(cheats_list.begin() + index);
}
void CheatEngine::UpdateCheat(int index, const std::shared_ptr<CheatBase>& new_cheat) {
void CheatEngine::UpdateCheat(std::size_t index, const std::shared_ptr<CheatBase>& new_cheat) {
std::unique_lock<std::shared_mutex> lock(cheats_list_mutex);
if (index < 0 || index >= static_cast<int>(cheats_list.size())) {
LOG_ERROR(Core_Cheats, "Invalid index {}", index);

View file

@ -29,8 +29,8 @@ public:
void Connect();
std::vector<std::shared_ptr<CheatBase>> GetCheats() const;
void AddCheat(const std::shared_ptr<CheatBase>& cheat);
void RemoveCheat(int index);
void UpdateCheat(int index, const std::shared_ptr<CheatBase>& new_cheat);
void RemoveCheat(std::size_t index);
void UpdateCheat(std::size_t index, const std::shared_ptr<CheatBase>& new_cheat);
void SaveCheatFile() const;
private:

View file

@ -705,7 +705,7 @@ static bool IsDataAvailable() {
fd_set fd_socket;
FD_ZERO(&fd_socket);
FD_SET(gdbserver_socket, &fd_socket);
FD_SET(static_cast<u32>(gdbserver_socket), &fd_socket);
struct timeval t;
t.tv_sec = 0;

View file

@ -198,7 +198,7 @@ void ExtraHID::HandleReadCalibrationDataRequest(const std::vector<u8>& request_b
const u16 offset = Common::AlignDown(request.offset, 16);
const u16 size = Common::AlignDown(request.size, 16);
if (offset + size > calibration_data.size()) {
if (static_cast<std::size_t>(offset + size) > calibration_data.size()) {
LOG_ERROR(Service_IR, "Read beyond the end of calibration data! (offset={}, size={})",
offset, size);
return;

View file

@ -93,8 +93,9 @@ static void SetShaderUniformBlockBinding(GLuint shader, const char* name, Unifor
}
GLint ub_size = 0;
glGetActiveUniformBlockiv(shader, ub_index, GL_UNIFORM_BLOCK_DATA_SIZE, &ub_size);
ASSERT_MSG(ub_size == expected_size, "Uniform block size did not match! Got {}, expected {}",
static_cast<int>(ub_size), expected_size);
ASSERT_MSG(static_cast<std::size_t>(ub_size) == expected_size,
"Uniform block size did not match! Got {}, expected {}", static_cast<int>(ub_size),
expected_size);
glUniformBlockBinding(shader, ub_index, static_cast<GLuint>(binding));
}

View file

@ -192,7 +192,8 @@ void JitShader::Compile_SwizzleSrc(Instruction instr, unsigned src_num, SourceRe
}
int src_offset_disp = (int)src_offset;
ASSERT_MSG(src_offset == src_offset_disp, "Source register offset too large for int type");
ASSERT_MSG(src_offset == static_cast<std::size_t>(src_offset_disp),
"Source register offset too large for int type");
unsigned operand_desc_id;