Skip to content

Commit

Permalink
cmake: toolchain: generalize exclusion of CXX options
Browse files Browse the repository at this point in the history
-Wold-style-definition is not a supported option for C++ builds.  To
prevent it being passed:
* the list of compiler flags to be excluded from C++ builds is moved
  to be toolchain-specific;
* -Wold-style-definition is added to that list for gcc and clang;
* -Wold-style-definition is moved from zephyr_compiler_options to
  zephyr_cc_option so the option checking code is executed for it.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
  • Loading branch information
pabigot committed Dec 16, 2019
1 parent 6ade720 commit 269bb2f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
9 changes: 8 additions & 1 deletion cmake/compiler/clang/target_warnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ macro(toolchain_cc_warning_dw_1)
-Wno-unused-parameter
-Wmissing-declarations
-Wmissing-format-attribute
-Wold-style-definition
)
zephyr_cc_option(
-Wold-style-definition
-Wmissing-prototypes
-Wmissing-include-dirs
-Wunused-but-set-variable
Expand Down Expand Up @@ -115,3 +115,10 @@ endmacro()
macro(toolchain_cc_cpp_warning_error_misra_sane dest_var_name)
set_ifndef(${dest_var_name} "-Werror=vla")
endmacro()

# List the warnings that are not supported for C++ compilations

list(APPEND CXX_EXCLUDED_OPTIONS
-Werror=implicit-int
-Wold-style-definition
)
9 changes: 8 additions & 1 deletion cmake/compiler/gcc/target_warnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ macro(toolchain_cc_warning_dw_1)
-Wno-unused-parameter
-Wmissing-declarations
-Wmissing-format-attribute
-Wold-style-definition
)
zephyr_cc_option(
-Wold-style-definition
-Wmissing-prototypes
-Wmissing-include-dirs
-Wunused-but-set-variable
Expand Down Expand Up @@ -108,3 +108,10 @@ endmacro()
macro(toolchain_cc_cpp_warning_error_misra_sane dest_var_name)
set_ifndef(${dest_var_name} "-Werror=vla")
endmacro()

# List the warnings that are not supported for C++ compilations

list(APPEND CXX_EXCLUDED_OPTIONS
-Werror=implicit-int
-Wold-style-definition
)
8 changes: 4 additions & 4 deletions cmake/extensions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -851,10 +851,10 @@ function(zephyr_check_compiler_flag lang option check)
endfunction()

function(zephyr_check_compiler_flag_hardcoded lang option check exists)
# -Werror=implicit-int is not supported for CXX and we are not able
# to automatically test for it because it produces a warning
# instead of an error during the test.
if((${lang} STREQUAL CXX) AND ("${option}" STREQUAL -Werror=implicit-int))
# Various flags that are not supported for CXX may not be testable
# because they would produce a warning instead of an error during
# the test. Exclude them by toolchain-specific blacklist.
if((${lang} STREQUAL CXX) AND ("${option}" IN_LIST CXX_EXCLUDED_OPTIONS))
set(check 0 PARENT_SCOPE)
set(exists 1 PARENT_SCOPE)
else()
Expand Down

0 comments on commit 269bb2f

Please sign in to comment.