toolchain: introduce macros to ignore -Wshadow
This introduces two macros TOOLCHAIN_IGNORE_WSHADOW_BEGIN and TOOLCHAIN_IGNORE_WSHADOW_END which can be used inside another macro to ignore -Wshadow for certain block of code. This is useful for common macros that may nest upon themselves (for example, logging). Signed-off-by: Daniel Leung <daniel.leung@intel.com>
This commit is contained in:
parent
ca6adf1364
commit
8dc9d89d29
|
@ -235,7 +235,9 @@ do { \
|
|||
CBPRINTF_STATIC_PACKAGE(NULL, 0, _plen, Z_LOG_MSG_ALIGN_OFFSET, _options, \
|
||||
__VA_ARGS__); \
|
||||
} \
|
||||
TOOLCHAIN_IGNORE_WSHADOW_BEGIN \
|
||||
struct log_msg *_msg; \
|
||||
TOOLCHAIN_IGNORE_WSHADOW_END \
|
||||
Z_LOG_MSG_ON_STACK_ALLOC(_msg, Z_LOG_MSG_LEN(_plen, 0)); \
|
||||
Z_LOG_ARM64_VLA_PROTECT(); \
|
||||
if (_plen != 0) { \
|
||||
|
|
|
@ -115,6 +115,28 @@
|
|||
#define TOOLCHAIN_HAS_C_AUTO_TYPE 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def TOOLCHAIN_IGNORE_WSHADOW_BEGIN
|
||||
* @brief Begin of block to ignore -Wshadow.
|
||||
*
|
||||
* To be used inside another macro.
|
||||
* Only for toolchain supporting _Pragma("GCC diagnostic ...").
|
||||
*/
|
||||
#ifndef TOOLCHAIN_IGNORE_WSHADOW_BEGIN
|
||||
#define TOOLCHAIN_IGNORE_WSHADOW_BEGIN
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @def TOOLCHAIN_IGNORE_WSHADOW_END
|
||||
* @brief End of block to ignore -Wshadow.
|
||||
*
|
||||
* To be used inside another macro.
|
||||
* Only for toolchain supporting _Pragma("GCC diagnostic ...").
|
||||
*/
|
||||
#ifndef TOOLCHAIN_IGNORE_WSHADOW_END
|
||||
#define TOOLCHAIN_IGNORE_WSHADOW_END
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Ensure that __BYTE_ORDER__ and related preprocessor definitions are defined,
|
||||
* and that they match the Kconfig option that is used in the code itself to
|
||||
|
|
|
@ -639,5 +639,12 @@ do { \
|
|||
#define FUNC_NO_STACK_PROTECTOR
|
||||
#endif
|
||||
|
||||
#define TOOLCHAIN_IGNORE_WSHADOW_BEGIN \
|
||||
_Pragma("GCC diagnostic push") \
|
||||
_Pragma("GCC diagnostic ignored \"-Wshadow\"")
|
||||
|
||||
#define TOOLCHAIN_IGNORE_WSHADOW_END \
|
||||
_Pragma("GCC diagnostic pop")
|
||||
|
||||
#endif /* !_LINKER */
|
||||
#endif /* ZEPHYR_INCLUDE_TOOLCHAIN_GCC_H_ */
|
||||
|
|
Loading…
Reference in a new issue