Skip to content

Commit 60ca233

Browse files
pabigotcarlescufi
authored andcommitted
cmake: toolchain: generalize exclusion of CXX options
-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 <[email protected]>
1 parent cb3670c commit 60ca233

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

cmake/compiler/clang/target_warnings.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ macro(toolchain_cc_warning_dw_1)
2727
-Wno-unused-parameter
2828
-Wmissing-declarations
2929
-Wmissing-format-attribute
30-
-Wold-style-definition
3130
)
3231
zephyr_cc_option(
32+
-Wold-style-definition
3333
-Wmissing-prototypes
3434
-Wmissing-include-dirs
3535
-Wunused-but-set-variable
@@ -115,3 +115,10 @@ endmacro()
115115
macro(toolchain_cc_cpp_warning_error_misra_sane dest_var_name)
116116
set_ifndef(${dest_var_name} "-Werror=vla")
117117
endmacro()
118+
119+
# List the warnings that are not supported for C++ compilations
120+
121+
list(APPEND CXX_EXCLUDED_OPTIONS
122+
-Werror=implicit-int
123+
-Wold-style-definition
124+
)

cmake/compiler/gcc/target_warnings.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ macro(toolchain_cc_warning_dw_1)
3434
-Wno-unused-parameter
3535
-Wmissing-declarations
3636
-Wmissing-format-attribute
37-
-Wold-style-definition
3837
)
3938
zephyr_cc_option(
39+
-Wold-style-definition
4040
-Wmissing-prototypes
4141
-Wmissing-include-dirs
4242
-Wunused-but-set-variable
@@ -108,3 +108,10 @@ endmacro()
108108
macro(toolchain_cc_cpp_warning_error_misra_sane dest_var_name)
109109
set_ifndef(${dest_var_name} "-Werror=vla")
110110
endmacro()
111+
112+
# List the warnings that are not supported for C++ compilations
113+
114+
list(APPEND CXX_EXCLUDED_OPTIONS
115+
-Werror=implicit-int
116+
-Wold-style-definition
117+
)

cmake/extensions.cmake

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -851,10 +851,10 @@ function(zephyr_check_compiler_flag lang option check)
851851
endfunction()
852852

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

0 commit comments

Comments
 (0)