2019-05-06 20:34:43 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
# See root CMakeLists.txt for description and expectations of these macros
|
|
|
|
|
2019-05-06 21:19:27 +08:00
|
|
|
macro(toolchain_cc_warning_base)
|
|
|
|
|
|
|
|
zephyr_compile_options(
|
|
|
|
-Wall
|
|
|
|
-Wformat
|
|
|
|
-Wformat-security
|
|
|
|
-Wno-format-zero-length
|
2019-06-04 20:59:53 +08:00
|
|
|
-Wno-main
|
|
|
|
)
|
|
|
|
|
|
|
|
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "9.1.0")
|
|
|
|
zephyr_compile_options(
|
2019-06-04 06:00:43 +08:00
|
|
|
# FIXME: Remove once #16587 is fixed
|
|
|
|
-Wno-address-of-packed-member
|
2019-05-06 21:19:27 +08:00
|
|
|
)
|
2019-06-04 20:59:53 +08:00
|
|
|
endif()
|
2019-05-06 21:19:27 +08:00
|
|
|
|
|
|
|
zephyr_cc_option(-Wno-pointer-sign)
|
|
|
|
|
|
|
|
# Prohibit void pointer arithmetic. Illegal in C99
|
|
|
|
zephyr_cc_option(-Wpointer-arith)
|
|
|
|
|
|
|
|
endmacro()
|
|
|
|
|
2019-05-06 20:34:43 +08:00
|
|
|
macro(toolchain_cc_warning_dw_1)
|
|
|
|
|
|
|
|
zephyr_compile_options(
|
|
|
|
-Wextra
|
|
|
|
-Wunused
|
|
|
|
-Wno-unused-parameter
|
|
|
|
-Wmissing-declarations
|
|
|
|
-Wmissing-format-attribute
|
|
|
|
)
|
|
|
|
zephyr_cc_option(
|
2019-12-14 21:33:52 +08:00
|
|
|
-Wold-style-definition
|
2019-05-06 20:34:43 +08:00
|
|
|
-Wmissing-prototypes
|
|
|
|
-Wmissing-include-dirs
|
|
|
|
-Wunused-but-set-variable
|
|
|
|
-Wno-missing-field-initializers
|
|
|
|
)
|
|
|
|
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(toolchain_cc_warning_dw_2)
|
|
|
|
|
|
|
|
zephyr_compile_options(
|
|
|
|
-Waggregate-return
|
|
|
|
-Wcast-align
|
|
|
|
-Wdisabled-optimization
|
|
|
|
-Wnested-externs
|
|
|
|
-Wshadow
|
|
|
|
)
|
|
|
|
zephyr_cc_option(
|
|
|
|
-Wlogical-op
|
|
|
|
-Wmissing-field-initializers
|
|
|
|
)
|
|
|
|
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(toolchain_cc_warning_dw_3)
|
|
|
|
|
|
|
|
zephyr_compile_options(
|
|
|
|
-Wbad-function-cast
|
|
|
|
-Wcast-qual
|
|
|
|
-Wconversion
|
|
|
|
-Wpacked
|
|
|
|
-Wpadded
|
|
|
|
-Wpointer-arith
|
|
|
|
-Wredundant-decls
|
|
|
|
-Wswitch-default
|
|
|
|
)
|
|
|
|
zephyr_cc_option(
|
|
|
|
-Wpacked-bitfield-compat
|
|
|
|
-Wvla
|
|
|
|
)
|
|
|
|
|
|
|
|
endmacro()
|
2019-05-06 21:21:58 +08:00
|
|
|
|
|
|
|
macro(toolchain_cc_warning_extended)
|
|
|
|
|
|
|
|
zephyr_cc_option(
|
|
|
|
-Wno-unused-but-set-variable
|
|
|
|
)
|
|
|
|
|
|
|
|
endmacro()
|
2019-05-16 18:53:58 +08:00
|
|
|
|
2019-05-16 18:58:40 +08:00
|
|
|
macro(toolchain_cc_warning_error_implicit_int)
|
|
|
|
|
|
|
|
# Force an error when things like SYS_INIT(foo, ...) occur with a missing header
|
|
|
|
zephyr_cc_option(-Werror=implicit-int)
|
|
|
|
|
|
|
|
endmacro()
|
|
|
|
|
2019-05-16 18:53:58 +08:00
|
|
|
#
|
|
|
|
# The following macros leaves it up to the root CMakeLists.txt to choose
|
|
|
|
# the variables in which to put the requested flags, and whether or not
|
|
|
|
# to call the macros
|
|
|
|
#
|
|
|
|
|
|
|
|
macro(toolchain_cc_warning_error_misra_sane dest_var_name)
|
|
|
|
set_ifndef(${dest_var_name} "-Werror=vla")
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
macro(toolchain_cc_cpp_warning_error_misra_sane dest_var_name)
|
|
|
|
set_ifndef(${dest_var_name} "-Werror=vla")
|
|
|
|
endmacro()
|
2019-12-14 21:33:52 +08:00
|
|
|
|
|
|
|
# List the warnings that are not supported for C++ compilations
|
|
|
|
|
|
|
|
list(APPEND CXX_EXCLUDED_OPTIONS
|
|
|
|
-Werror=implicit-int
|
|
|
|
-Wold-style-definition
|
|
|
|
)
|