From b4f9032a39a1145b8b759696d54769f637705101 Mon Sep 17 00:00:00 2001 From: Ryan McClelland Date: Sat, 22 Apr 2023 14:23:57 -0700 Subject: [PATCH] cmake: compiler: add double promotion warning Too many times, code is pushed that includes floats that really becomes doubles and C implicit promotion rules will want to make floats into doubles very easily. As zephyr primarily targets low-end process that may not have a double precision floating point unit, enable this flag globally for now. Signed-off-by: Ryan McClelland --- cmake/compiler/arcmwdt/compiler_flags.cmake | 3 +++ cmake/compiler/clang/compiler_flags.cmake | 3 +++ cmake/compiler/gcc/compiler_flags.cmake | 3 +++ 3 files changed, 9 insertions(+) diff --git a/cmake/compiler/arcmwdt/compiler_flags.cmake b/cmake/compiler/arcmwdt/compiler_flags.cmake index 2b85dadf5a7e2a8..ae4d63d6b49bd2a 100644 --- a/cmake/compiler/arcmwdt/compiler_flags.cmake +++ b/cmake/compiler/arcmwdt/compiler_flags.cmake @@ -33,6 +33,9 @@ set_compiler_property(PROPERTY warning_base -Wno-typedef-redefinition ) +# C implicit promotion rules will want to make floats into doubles very easily +check_set_compiler_property(APPEND PROPERTY warning_base -Wdouble-promotion) + check_set_compiler_property(APPEND PROPERTY warning_base -Wno-pointer-sign) # Prohibit void pointer arithmetic. Illegal in C99 diff --git a/cmake/compiler/clang/compiler_flags.cmake b/cmake/compiler/clang/compiler_flags.cmake index 7a3fbdc1c3a8959..2ca26d50a9f10c4 100644 --- a/cmake/compiler/clang/compiler_flags.cmake +++ b/cmake/compiler/clang/compiler_flags.cmake @@ -38,6 +38,9 @@ check_set_compiler_property(PROPERTY warning_base -Wno-deprecated-non-prototype ) +# C implicit promotion rules will want to make floats into doubles very easily +check_set_compiler_property(APPEND PROPERTY warning_base -Wdouble-promotion) + check_set_compiler_property(APPEND PROPERTY warning_base -Wno-pointer-sign) # Prohibit void pointer arithmetic. Illegal in C99 diff --git a/cmake/compiler/gcc/compiler_flags.cmake b/cmake/compiler/gcc/compiler_flags.cmake index 96f87fcff0597cb..be914c5dd8b3ace 100644 --- a/cmake/compiler/gcc/compiler_flags.cmake +++ b/cmake/compiler/gcc/compiler_flags.cmake @@ -32,6 +32,9 @@ check_set_compiler_property(PROPERTY warning_base "SHELL:-Wformat -Wno-format-zero-length" ) +# C implicit promotion rules will want to make floats into doubles very easily +check_set_compiler_property(APPEND PROPERTY warning_base -Wdouble-promotion) + check_set_compiler_property(APPEND PROPERTY warning_base -Wno-pointer-sign) # Prohibit void pointer arithmetic. Illegal in C99