Skip to content

Commit 568779e

Browse files
committed
Raise MSVC warning level from /W3 to /W4
This patch increases the warning level when using the MSVC compiler from `/W3` to `/W4` and fixes the issues found. Four warnings introduced by `/W4` are disabled, all related to variable name shadowing, as they overly prescriptive to valid code.
1 parent 1d1808a commit 568779e

File tree

35 files changed

+97
-71
lines changed

35 files changed

+97
-71
lines changed

cmake/helpers.cmake

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ function(add_ur_target_compile_options name)
8282
elseif(MSVC)
8383
target_compile_options(${name} PRIVATE
8484
$<$<CXX_COMPILER_ID:MSVC>:/MP> # clang-cl.exe does not support /MP
85-
/W3
85+
/W4
86+
/wd4456 # Disable: declaration of 'identifier' hides previous local declaration
87+
/wd4457 # Disable: declaration of 'identifier' hides function parameter
88+
/wd4458 # Disable: declaration of 'identifier' hides class member
89+
/wd4459 # Disable: declaration of 'identifier' hides global declaration
8690
/MD$<$<CONFIG:Debug>:d>
8791
/GS
8892
/DWIN32_LEAN_AND_MEAN

examples/collector/collector.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@
2525
#include <string_view>
2626

2727
#include "ur_api.h"
28+
29+
#ifdef _MSC_VER
30+
#pragma warning(disable : 4245)
31+
#endif
2832
#include "xpti/xpti_trace_framework.h"
33+
#ifdef _MSC_VER
34+
#pragma warning(default : 4245)
35+
#endif
2936

3037
constexpr uint16_t TRACE_FN_BEGIN =
3138
static_cast<uint16_t>(xpti::trace_point_type_t::function_with_args_begin);

include/ur_api.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ typedef struct ur_physical_mem_handle_t_ *ur_physical_mem_handle_t;
422422
///////////////////////////////////////////////////////////////////////////////
423423
#ifndef UR_BIT
424424
/// @brief Generic macro for enumerator bit masks
425-
#define UR_BIT(_i) (1 << _i)
425+
#define UR_BIT(_i) (1U << _i)
426426
#endif // UR_BIT
427427

428428
///////////////////////////////////////////////////////////////////////////////

scripts/core/common.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ name: "$x_physical_mem_handle_t"
134134
type: macro
135135
desc: "Generic macro for enumerator bit masks"
136136
name: "$X_BIT( _i )"
137-
value: "( 1 << _i )"
137+
value: "( 1U << _i )"
138138
--- #--------------------------------------------------------------------------
139139
type: enum
140140
desc: "Defines Return/Error codes"

source/adapters/level_zero/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ if (NOT DEFINED LEVEL_ZERO_LIBRARY OR NOT DEFINED LEVEL_ZERO_INCLUDE_DIR)
6565

6666
target_compile_options(ze_loader PRIVATE
6767
$<$<IN_LIST:$<CXX_COMPILER_ID>,GNU;Clang;Intel;IntelLLVM>:-Wno-error>
68-
$<$<CXX_COMPILER_ID:MSVC>:/WX- /UUNICODE>
68+
$<$<CXX_COMPILER_ID:MSVC>:/UUNICODE>
6969
)
7070

7171
set(LEVEL_ZERO_LIBRARY ze_loader)
@@ -256,7 +256,7 @@ if(UR_BUILD_ADAPTER_L0_V2)
256256

257257
# TODO: fix level_zero adapter conversion warnings
258258
target_compile_options(ur_adapter_level_zero_v2 PRIVATE
259-
$<$<CXX_COMPILER_ID:MSVC>:/wd4805 /wd4244>
259+
$<$<CXX_COMPILER_ID:MSVC>:/wd4805 /wd4244 /wd4100>
260260
)
261261

262262
set_target_properties(ur_adapter_level_zero_v2 PROPERTIES

source/adapters/level_zero/adapter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,5 @@ ur_result_t urAdapterGetInfo(ur_adapter_handle_t, ur_adapter_info_t PropName,
378378
default:
379379
return UR_RESULT_ERROR_INVALID_ENUMERATION;
380380
}
381-
382-
return UR_RESULT_SUCCESS;
383381
}
384382
} // namespace ur::level_zero

source/adapters/level_zero/context.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ ur_result_t ur_context_handle_t_::getAvailableCommandList(
756756
// queue's map to hold the fence and other associated command
757757
// list information.
758758
auto &QGroup = Queue->getQueueGroup(UseCopyEngine);
759-
uint32_t QueueGroupOrdinal;
759+
uint32_t QueueGroupOrdinal = 0;
760760
auto &ZeCommandQueue = ForcedCmdQueue
761761
? *ForcedCmdQueue
762762
: QGroup.getZeQueue(&QueueGroupOrdinal);

source/adapters/level_zero/device.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,8 +1110,6 @@ ur_result_t urDeviceGetInfo(
11101110
logger::toHex(ParamName));
11111111
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
11121112
}
1113-
1114-
return UR_RESULT_SUCCESS;
11151113
}
11161114

11171115
bool CopyEngineRequested(const ur_device_handle_t &Device) {

source/adapters/level_zero/event.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,8 +479,6 @@ ur_result_t urEventGetInfo(
479479
PropName, logger::toHex(PropName));
480480
return UR_RESULT_ERROR_INVALID_VALUE;
481481
}
482-
483-
return UR_RESULT_SUCCESS;
484482
}
485483

486484
ur_result_t urEventGetProfilingInfo(

source/adapters/level_zero/platform.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ ur_result_t urPlatformGetInfo(
9999
logger::debug("urPlatformGetInfo: unrecognized ParamName");
100100
return UR_RESULT_ERROR_INVALID_VALUE;
101101
}
102-
103-
return UR_RESULT_SUCCESS;
104102
}
105103

106104
ur_result_t urPlatformGetApiVersion(

0 commit comments

Comments
 (0)