Skip to content

Commit ad21524

Browse files
authored
fix: few CI errors caused by recently enabled compilation flags (#4620)
- add missing warning for incompatible pointer types in CMake configuration - fix a shadow warning
1 parent d7afa4c commit ad21524

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

build-scripts/warnings.cmake

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,28 @@ else ()
1616
#
1717
# -fpermissive causes warnings like "-fpermissive is valid for C++/ObjC++ but not for C"
1818
#
19+
# Reference:
20+
# - gcc-4.8 https://gcc.gnu.org/onlinedocs/gcc-4.8.4/gcc/Warning-Options.html
21+
# - gcc-11.5 https://gcc.gnu.org/onlinedocs/gcc-11.5.0/gcc/Warning-Options.html
1922
add_compile_options (
20-
$<$<COMPILE_LANGUAGE:C>:-Wincompatible-pointer-types>
2123
$<$<COMPILE_LANGUAGE:C>:-Wimplicit-function-declaration>
2224
)
25+
26+
# https://gcc.gnu.org/gcc-5/changes.html introduces incompatible-pointer-types
27+
# https://releases.llvm.org/7.0.0/tools/clang/docs/DiagnosticsReference.html#wincompatible-pointer-types
28+
# is the earliest version that supports this option I can found.
29+
# Assume AppClang versioning is compatible with Clang.
30+
if ((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "5.1")
31+
OR (CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0.0")
32+
OR (CMAKE_C_COMPILER_ID STREQUAL "AppClang" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0.0"))
33+
add_compile_options($<$<COMPILE_LANGUAGE:C>:-Wincompatible-pointer-types>)
34+
endif()
35+
36+
# options benefit embedded system.
2337
add_compile_options (
2438
-Wdouble-promotion
2539
)
40+
2641
# waivers
2742
add_compile_options (
2843
-Wno-unused

core/iwasm/interpreter/wasm_loader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7495,7 +7495,7 @@ wasm_loader_unload(WASMModule *module)
74957495
#endif
74967496
#endif
74977497
#if WASM_ENABLE_BRANCH_HINTS != 0
7498-
for (size_t i = 0; i < module->function_count; i++) {
7498+
for (i = 0; i < module->function_count; i++) {
74997499
// be carefull when adding more hints. This only works as long as
75007500
// the hint structs have been allocated all at once as an array.
75017501
// With only branch-hints at the moment, this is the case.

0 commit comments

Comments
 (0)