Skip to content

Commit becfd02

Browse files
LoveKarlssonkartben
authored andcommitted
toolchain: Add IAR warning macros
Add warning macros for IAR tools analogue to CLANG and GCC. Signed-off-by: Lars-Ove Karlsson <[email protected]>
1 parent 22ea55c commit becfd02

File tree

2 files changed

+137
-2
lines changed

2 files changed

+137
-2
lines changed

include/zephyr/toolchain.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,24 @@
300300
#define TOOLCHAIN_ENABLE_GCC_WARNING(warning)
301301
#endif
302302

303+
/**
304+
* @def TOOLCHAIN_DISABLE_IAR_WARNING
305+
* @brief Disable the specified compiler warning for IAR compilers.
306+
*/
307+
#ifndef TOOLCHAIN_DISABLE_IAR_WARNING
308+
#define TOOLCHAIN_DISABLE_IAR_WARNING(warning)
309+
#endif
310+
311+
/**
312+
* @def TOOLCHAIN_ENABLE_IAR_WARNING
313+
* @brief Re-enable the specified compiler warning for IAR compilers.
314+
*
315+
* Can only be used after a call to @ref TOOLCHAIN_DISABLE_IAR_WARNING.
316+
*/
317+
#ifndef TOOLCHAIN_ENABLE_IAR_WARNING
318+
#define TOOLCHAIN_ENABLE_IAR_WARNING(warning)
319+
#endif
320+
303321
/*
304322
* Ensure that __BYTE_ORDER__ and related preprocessor definitions are defined,
305323
* and that they match the Kconfig option that is used in the code itself to

include/zephyr/toolchain/iar.h

Lines changed: 119 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,131 @@
77
#ifndef ZEPHYR_INCLUDE_TOOLCHAIN_IAR_H_
88
#define ZEPHYR_INCLUDE_TOOLCHAIN_IAR_H_
99

10-
#ifdef TOOLCHAIN_PRAGMA
10+
#define TOOLCHAIN_HAS_PRAGMA_DIAG
11+
1112
#define _TOOLCHAIN_DISABLE_WARNING(warning) TOOLCHAIN_PRAGMA(diag_suppress = warning)
12-
#define _TOOLCHAIN_ENABLE_WARNING(warning) TOOLCHAIN_PRAGMA(diag_default = warning)
13+
#define _TOOLCHAIN_ENABLE_WARNING(warning) TOOLCHAIN_PRAGMA(diag_default = warning)
1314

1415
#define TOOLCHAIN_DISABLE_WARNING(warning) _TOOLCHAIN_DISABLE_WARNING(warning)
1516
#define TOOLCHAIN_ENABLE_WARNING(warning) _TOOLCHAIN_ENABLE_WARNING(warning)
17+
18+
#define TOOLCHAIN_DISABLE_IAR_WARNING(warning) _TOOLCHAIN_DISABLE_WARNING(warning)
19+
#define TOOLCHAIN_ENABLE_IAR_WARNING(warning) _TOOLCHAIN_ENABLE_WARNING(warning)
20+
21+
/* Generic warnings */
22+
23+
24+
/**
25+
* @def TOOLCHAIN_WARNING_ADDRESS_OF_PACKED_MEMBER
26+
* @brief Toolchain-specific warning for taking the address of a packed member.
27+
*
28+
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
29+
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
30+
*/
31+
#ifndef TOOLCHAIN_WARNING_ADDRESS_OF_PACKED_MEMBER
32+
#define TOOLCHAIN_WARNING_ADDRESS_OF_PACKED_MEMBER Pe001
33+
#endif
34+
35+
/**
36+
* @def TOOLCHAIN_WARNING_ARRAY_BOUNDS
37+
* @brief Toolchain-specific warning for array bounds violations.
38+
*
39+
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
40+
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
41+
*/
42+
#ifndef TOOLCHAIN_WARNING_ARRAY_BOUNDS
43+
#define TOOLCHAIN_WARNING_ARRAY_BOUNDS Pe001
1644
#endif
1745

46+
/**
47+
* @def TOOLCHAIN_WARNING_ATTRIBUTES
48+
* @brief Toolchain-specific warning for unknown attributes.
49+
*
50+
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
51+
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
52+
*/
53+
#ifndef TOOLCHAIN_WARNING_ATTRIBUTES
54+
#define TOOLCHAIN_WARNING_ATTRIBUTES Pe1097
55+
#endif
56+
57+
/**
58+
* @def TOOLCHAIN_WARNING_DELETE_NON_VIRTUAL_DTOR
59+
* @brief Toolchain-specific warning for deleting a pointer to an object
60+
* with a non-virtual destructor.
61+
*
62+
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
63+
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
64+
*/
65+
#ifndef TOOLCHAIN_WARNING_DELETE_NON_VIRTUAL_DTOR
66+
#define TOOLCHAIN_WARNING_DELETE_NON_VIRTUAL_DTOR Pe001
67+
#endif
68+
69+
/**
70+
* @def TOOLCHAIN_WARNING_EXTRA
71+
* @brief Toolchain-specific warning for extra warnings.
72+
*
73+
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
74+
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
75+
*/
76+
#ifndef TOOLCHAIN_WARNING_EXTRA
77+
#define TOOLCHAIN_WARNING_EXTRA Pe001
78+
#endif
79+
80+
/**
81+
* @def TOOLCHAIN_WARNING_NONNULL
82+
* @brief Toolchain-specific warning for null pointer arguments to functions marked with "nonnull".
83+
*
84+
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
85+
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
86+
*/
87+
#ifndef TOOLCHAIN_WARNING_NONNULL
88+
#define TOOLCHAIN_WARNING_NONNULL Pe001
89+
#endif
90+
91+
/**
92+
* @def TOOLCHAIN_WARNING_POINTER_ARITH
93+
* @brief Toolchain-specific warning for pointer arithmetic.
94+
*
95+
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
96+
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
97+
*/
98+
#ifndef TOOLCHAIN_WARNING_POINTER_ARITH
99+
#define TOOLCHAIN_WARNING_POINTER_ARITH Pe1143
100+
#endif
101+
102+
/**
103+
* @def TOOLCHAIN_WARNING_SHADOW
104+
* @brief Toolchain-specific warning for shadow variables.
105+
*
106+
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
107+
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
108+
*/
109+
#ifndef TOOLCHAIN_WARNING_SHADOW
110+
#define TOOLCHAIN_WARNING_SHADOW Pe001
111+
#endif
112+
113+
/**
114+
* @def TOOLCHAIN_WARNING_UNUSED_LABEL
115+
* @brief Toolchain-specific warning for unused labels.
116+
*
117+
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
118+
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
119+
*/
120+
#ifndef TOOLCHAIN_WARNING_UNUSED_LABEL
121+
#define TOOLCHAIN_WARNING_UNUSED_LABEL Pe001
122+
#endif
123+
124+
/**
125+
* @def TOOLCHAIN_WARNING_UNUSED_VARIABLE
126+
* @brief Toolchain-specific warning for unused variables.
127+
*
128+
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
129+
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
130+
*/
131+
#define TOOLCHAIN_WARNING_UNUSED_VARIABLE Pe001
132+
133+
#define TOOLCHAIN_WARNING_UNUSED_FUNCTION Pe001
134+
18135
#ifdef __ICCARM__
19136
#include "iar/iccarm.h"
20137
#endif

0 commit comments

Comments
 (0)