everywhere: Use correct macro for gcc-specific warnings
Many warnings were disabled for all compilers, even though they are gcc-specific warnings. Now that clang has -Wunknown-warning-option enabled, this can cause compilation failures when building with clang toolchains. Use TOOLCHAIN_DISABLE_GCC_WARNING for all gcc-specific macros. https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html https://clang.llvm.org/docs/DiagnosticsReference.html Fixes: #84138 Signed-off-by: Tom Hughes <tomhughes@chromium.org>
This commit is contained in:
parent
11d70c61e5
commit
15411747e7
8 changed files with 20 additions and 19 deletions
|
@ -262,9 +262,9 @@ static inline char z_log_minimal_level_to_char(int level)
|
||||||
GET_ARG_N(1, __VA_ARGS__))
|
GET_ARG_N(1, __VA_ARGS__))
|
||||||
|
|
||||||
#define LOG_POINTERS_VALIDATE(string_ok, ...) \
|
#define LOG_POINTERS_VALIDATE(string_ok, ...) \
|
||||||
TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH); \
|
TOOLCHAIN_DISABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH); \
|
||||||
string_ok = Z_CBPRINTF_POINTERS_VALIDATE(__VA_ARGS__); \
|
string_ok = Z_CBPRINTF_POINTERS_VALIDATE(__VA_ARGS__); \
|
||||||
TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
TOOLCHAIN_ENABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
||||||
#else
|
#else
|
||||||
#define LOG_POINTERS_VALIDATE(string_ok, ...) string_ok = true
|
#define LOG_POINTERS_VALIDATE(string_ok, ...) string_ok = true
|
||||||
#define LOG_STRING_WARNING(_mode, _src, ...)
|
#define LOG_STRING_WARNING(_mode, _src, ...)
|
||||||
|
|
|
@ -569,9 +569,9 @@ do { \
|
||||||
#define Z_LOG_MSG_CREATE2(_try_0cpy, _mode, _cstr_cnt, _domain_id, _source, \
|
#define Z_LOG_MSG_CREATE2(_try_0cpy, _mode, _cstr_cnt, _domain_id, _source, \
|
||||||
_level, _data, _dlen, ...) \
|
_level, _data, _dlen, ...) \
|
||||||
do { \
|
do { \
|
||||||
TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH); \
|
TOOLCHAIN_DISABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH); \
|
||||||
FOR_EACH_IDX(Z_LOG_LOCAL_ARG_CREATE, (;), __VA_ARGS__); \
|
FOR_EACH_IDX(Z_LOG_LOCAL_ARG_CREATE, (;), __VA_ARGS__); \
|
||||||
TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH); \
|
TOOLCHAIN_ENABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH); \
|
||||||
Z_LOG_MSG_CREATE3(_try_0cpy, _mode, _cstr_cnt, _domain_id, _source,\
|
Z_LOG_MSG_CREATE3(_try_0cpy, _mode, _cstr_cnt, _domain_id, _source,\
|
||||||
_level, _data, _dlen, \
|
_level, _data, _dlen, \
|
||||||
FOR_EACH_IDX(Z_LOG_LOCAL_ARG_NAME, (,), __VA_ARGS__)); \
|
FOR_EACH_IDX(Z_LOG_LOCAL_ARG_NAME, (,), __VA_ARGS__)); \
|
||||||
|
|
|
@ -81,10 +81,10 @@ template < typename T >
|
||||||
static inline int z_cbprintf_cxx_is_pchar(T arg, bool const_as_fixed)
|
static inline int z_cbprintf_cxx_is_pchar(T arg, bool const_as_fixed)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(arg);
|
ARG_UNUSED(arg);
|
||||||
TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
TOOLCHAIN_DISABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
||||||
ARG_UNUSED(const_as_fixed);
|
ARG_UNUSED(const_as_fixed);
|
||||||
return 0;
|
return 0;
|
||||||
TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
TOOLCHAIN_ENABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* C++ version for determining if variable type is numeric and fits in 32 bit word. */
|
/* C++ version for determining if variable type is numeric and fits in 32 bit word. */
|
||||||
|
@ -132,9 +132,9 @@ template < typename T >
|
||||||
static inline int z_cbprintf_cxx_is_word_num(T arg)
|
static inline int z_cbprintf_cxx_is_word_num(T arg)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(arg);
|
ARG_UNUSED(arg);
|
||||||
TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
TOOLCHAIN_DISABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
||||||
return 0;
|
return 0;
|
||||||
TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
TOOLCHAIN_ENABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* C++ version for determining if argument is a none character pointer. */
|
/* C++ version for determining if argument is a none character pointer. */
|
||||||
|
|
|
@ -530,14 +530,14 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
#if Z_C_GENERIC
|
#if Z_C_GENERIC
|
||||||
#define Z_CBPRINTF_MUST_RUNTIME_PACKAGE(flags, ...) ({\
|
#define Z_CBPRINTF_MUST_RUNTIME_PACKAGE(flags, ...) ({\
|
||||||
TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH); \
|
TOOLCHAIN_DISABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH); \
|
||||||
int _rv; \
|
int _rv; \
|
||||||
if ((flags) & CBPRINTF_PACKAGE_ADD_RW_STR_POS) { \
|
if ((flags) & CBPRINTF_PACKAGE_ADD_RW_STR_POS) { \
|
||||||
_rv = 0; \
|
_rv = 0; \
|
||||||
} else { \
|
} else { \
|
||||||
_rv = Z_CBPRINTF_PCHAR_COUNT(flags, __VA_ARGS__) > 0 ? 1 : 0; \
|
_rv = Z_CBPRINTF_PCHAR_COUNT(flags, __VA_ARGS__) > 0 ? 1 : 0; \
|
||||||
} \
|
} \
|
||||||
TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH); \
|
TOOLCHAIN_ENABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH); \
|
||||||
_rv; \
|
_rv; \
|
||||||
})
|
})
|
||||||
#else
|
#else
|
||||||
|
@ -765,7 +765,7 @@ do { \
|
||||||
#define Z_CBPRINTF_STATIC_PACKAGE_GENERIC(buf, _inlen, _outlen, _align_offset, \
|
#define Z_CBPRINTF_STATIC_PACKAGE_GENERIC(buf, _inlen, _outlen, _align_offset, \
|
||||||
flags, ... /* fmt, ... */) \
|
flags, ... /* fmt, ... */) \
|
||||||
do { \
|
do { \
|
||||||
TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH); \
|
TOOLCHAIN_DISABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH); \
|
||||||
BUILD_ASSERT(!IS_ENABLED(CONFIG_XTENSA) || \
|
BUILD_ASSERT(!IS_ENABLED(CONFIG_XTENSA) || \
|
||||||
(IS_ENABLED(CONFIG_XTENSA) && \
|
(IS_ENABLED(CONFIG_XTENSA) && \
|
||||||
!((_align_offset) % CBPRINTF_PACKAGE_ALIGNMENT)), \
|
!((_align_offset) % CBPRINTF_PACKAGE_ALIGNMENT)), \
|
||||||
|
@ -843,7 +843,7 @@ do { \
|
||||||
(pkg_hdr.desc.pkg_flags = flags)); \
|
(pkg_hdr.desc.pkg_flags = flags)); \
|
||||||
*_len_loc = pkg_hdr; \
|
*_len_loc = pkg_hdr; \
|
||||||
} \
|
} \
|
||||||
TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH); \
|
TOOLCHAIN_ENABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH); \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
#if Z_C_GENERIC
|
#if Z_C_GENERIC
|
||||||
|
|
|
@ -19,7 +19,7 @@ volatile unsigned int changed;
|
||||||
* The `alternate_thread` function deliberately makes use of a dangling pointer
|
* The `alternate_thread` function deliberately makes use of a dangling pointer
|
||||||
* in order to test stack randomisation.
|
* in order to test stack randomisation.
|
||||||
*/
|
*/
|
||||||
TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_DANGLING_POINTER)
|
TOOLCHAIN_DISABLE_GCC_WARNING(TOOLCHAIN_WARNING_DANGLING_POINTER)
|
||||||
|
|
||||||
void alternate_thread(void *p1, void *p2, void *p3)
|
void alternate_thread(void *p1, void *p2, void *p3)
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,7 @@ void alternate_thread(void *p1, void *p2, void *p3)
|
||||||
last_sp = sp_val;
|
last_sp = sp_val;
|
||||||
}
|
}
|
||||||
|
|
||||||
TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_DANGLING_POINTER)
|
TOOLCHAIN_ENABLE_GCC_WARNING(TOOLCHAIN_WARNING_DANGLING_POINTER)
|
||||||
|
|
||||||
K_THREAD_STACK_DEFINE(alt_thread_stack_area, STACKSIZE);
|
K_THREAD_STACK_DEFINE(alt_thread_stack_area, STACKSIZE);
|
||||||
static struct k_thread alt_thread_data;
|
static struct k_thread alt_thread_data;
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
/*
|
/*
|
||||||
* Don't complain about ridiculous alloc size requests
|
* Don't complain about ridiculous alloc size requests
|
||||||
*/
|
*/
|
||||||
TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_ALLOC_SIZE_LARGER_THAN)
|
TOOLCHAIN_DISABLE_GCC_WARNING(TOOLCHAIN_WARNING_ALLOC_SIZE_LARGER_THAN)
|
||||||
|
|
||||||
#define TOO_BIG PTRDIFF_MAX
|
#define TOO_BIG PTRDIFF_MAX
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <zephyr/ztest.h>
|
#include <zephyr/ztest.h>
|
||||||
|
#include <zephyr/test_toolchain.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
|
|
@ -1365,7 +1365,7 @@ ZTEST(prf, test_is_none_char_ptr)
|
||||||
float f = 0.1;
|
float f = 0.1;
|
||||||
double d = 0.1;
|
double d = 0.1;
|
||||||
|
|
||||||
TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
TOOLCHAIN_DISABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
||||||
zassert_equal(Z_CBPRINTF_IS_NONE_CHAR_PTR(c), 0);
|
zassert_equal(Z_CBPRINTF_IS_NONE_CHAR_PTR(c), 0);
|
||||||
zassert_equal(Z_CBPRINTF_IS_NONE_CHAR_PTR(cc), 0);
|
zassert_equal(Z_CBPRINTF_IS_NONE_CHAR_PTR(cc), 0);
|
||||||
zassert_equal(Z_CBPRINTF_IS_NONE_CHAR_PTR(vc), 0);
|
zassert_equal(Z_CBPRINTF_IS_NONE_CHAR_PTR(vc), 0);
|
||||||
|
@ -1413,7 +1413,7 @@ ZTEST(prf, test_is_none_char_ptr)
|
||||||
|
|
||||||
zassert_equal(Z_CBPRINTF_IS_NONE_CHAR_PTR((void *)&c), 1);
|
zassert_equal(Z_CBPRINTF_IS_NONE_CHAR_PTR((void *)&c), 1);
|
||||||
|
|
||||||
TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
TOOLCHAIN_ENABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
||||||
}
|
}
|
||||||
|
|
||||||
ZTEST(prf, test_p_count)
|
ZTEST(prf, test_p_count)
|
||||||
|
@ -1427,12 +1427,12 @@ ZTEST(prf, test_p_count)
|
||||||
|
|
||||||
ZTEST(prf, test_pointers_validate)
|
ZTEST(prf, test_pointers_validate)
|
||||||
{
|
{
|
||||||
TOOLCHAIN_DISABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
TOOLCHAIN_DISABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
||||||
zassert_equal(Z_CBPRINTF_POINTERS_VALIDATE("no arguments"), true);
|
zassert_equal(Z_CBPRINTF_POINTERS_VALIDATE("no arguments"), true);
|
||||||
/* const char fails validation */
|
/* const char fails validation */
|
||||||
zassert_equal(Z_CBPRINTF_POINTERS_VALIDATE("%p", "string"), false);
|
zassert_equal(Z_CBPRINTF_POINTERS_VALIDATE("%p", "string"), false);
|
||||||
zassert_equal(Z_CBPRINTF_POINTERS_VALIDATE("%p", (void *)"string"), true);
|
zassert_equal(Z_CBPRINTF_POINTERS_VALIDATE("%p", (void *)"string"), true);
|
||||||
TOOLCHAIN_ENABLE_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
TOOLCHAIN_ENABLE_GCC_WARNING(TOOLCHAIN_WARNING_POINTER_ARITH);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *cbprintf_setup(void)
|
static void *cbprintf_setup(void)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue