Skip to content

Commit 0258e15

Browse files
authored
avoid -Wuseless-cast GCC warnings with TinyXML-2 (#7499)
``` In file included from /home/user/cppcheck/externals/tinyxml2/tinyxml2.cpp:24: /home/user/cppcheck/externals/tinyxml2/tinyxml2.h:442:26: warning: useless cast to type ‘size_t’ {aka ‘long unsigned int’} [-Wuseless-cast] 442 | char itemData[static_cast<size_t>(ITEM_SIZE)]; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ```
1 parent d8d4ea3 commit 0258e15

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

externals/tinyxml2/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ endif()
99
# TODO: needs to be fixed upstream
1010
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
1111
target_compile_options(tinyxml2_objs PRIVATE -Wno-suggest-attribute=format)
12+
target_compile_options(tinyxml2_objs PRIVATE -Wno-useless-cast)
1213
endif()
1314
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1415
target_compile_options_safe(tinyxml2_objs -Wno-implicit-fallthrough)

lib/xml.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#if defined(__GNUC__) && (__GNUC__ >= 14)
2626
SUPPRESS_WARNING_GCC_PUSH("-Wsuggest-attribute=returns_nonnull")
2727
#endif
28+
SUPPRESS_WARNING_GCC_PUSH("-Wuseless-cast")
2829
SUPPRESS_WARNING_CLANG_PUSH("-Wzero-as-null-pointer-constant")
2930
SUPPRESS_WARNING_CLANG_PUSH("-Wsuggest-destructor-override")
3031
SUPPRESS_WARNING_CLANG_PUSH("-Winconsistent-missing-destructor-override")
@@ -34,6 +35,7 @@ SUPPRESS_WARNING_CLANG_PUSH("-Winconsistent-missing-destructor-override")
3435
SUPPRESS_WARNING_CLANG_POP
3536
SUPPRESS_WARNING_CLANG_POP
3637
SUPPRESS_WARNING_CLANG_POP
38+
SUPPRESS_WARNING_GCC_POP
3739
#if defined(__GNUC__) && (__GNUC__ >= 14)
3840
SUPPRESS_WARNING_GCC_POP
3941
#endif

0 commit comments

Comments
 (0)