diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-08-29 16:00:24 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-10-13 19:57:39 +0000 |
commit | dc6a5f010be58345289bfb9d2f86153ef35b2223 (patch) | |
tree | 133ba24d0d177079285c7a43ee70c66ca89c9990 /core | |
parent | b6e08b63154cd9370f5206b7a3f928b44c31478d (diff) | |
download | chrome-ec-dc6a5f010be58345289bfb9d2f86153ef35b2223.tar.gz |
include/compiler.h: Add generic macro for disabling compiler warnings
These macros are easier to read and use than the underlying pragmas.
BRANCH=none
BUG=b:172020503
TEST=make buildall
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I2f67cbb3f83230b7e1a6a4512471bbd2bec0498f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3872552
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Code-Coverage: Zoss <zoss-cl-coverage@prod.google.com>
Diffstat (limited to 'core')
-rw-r--r-- | core/cortex-m/vecttable.c | 17 | ||||
-rw-r--r-- | core/cortex-m0/vecttable.c | 10 |
2 files changed, 8 insertions, 19 deletions
diff --git a/core/cortex-m/vecttable.c b/core/cortex-m/vecttable.c index 433898c00a..037bc28c36 100644 --- a/core/cortex-m/vecttable.c +++ b/core/cortex-m/vecttable.c @@ -7,6 +7,7 @@ #ifndef ___INIT #define ___INIT +#include "compiler.h" #include "config.h" #include <task.h> #endif @@ -39,13 +40,10 @@ void default_handler(void) extern void stack_end(void); /* not technically correct, it's just a pointer */ extern void reset(void); -#pragma GCC diagnostic push -#if __GNUC__ >= 8 -#pragma GCC diagnostic ignored "-Wattribute-alias" -#endif +DISABLE_GCC_WARNING("-Wattribute-alias") /* Call default_handler if svc_handler is not found (task.c is not built) */ void weak_with_default svc_handler(int desched, task_id_t resched); -#pragma GCC diagnostic pop +ENABLE_GCC_WARNING("-Wattribute-alias") /* * SVC handler helper @@ -91,10 +89,7 @@ void svc_helper_handler(void) /* Disable warning that "initializer overrides prior initialization of this * subobject", since we are explicitly doing this to handle the unused IRQs. */ -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Winitializer-overrides" -#endif /* __clang__ */ +DISABLE_CLANG_WARNING("-Winitializer-overrides") #define table(x) \ const func vectors[] __attribute__((section( \ @@ -156,9 +151,7 @@ table(item(stack_end) item(reset) vec(nmi) vec(hard_fault) vec(mpu_fault) vec( irq(239)) #if PASS == 2 -#ifdef __clang__ -#pragma clang diagnostic pop -#endif /* __clang__ */ + ENABLE_CLANG_WARNING("-Winitializer-overrides") #endif #if PASS == 1 diff --git a/core/cortex-m0/vecttable.c b/core/cortex-m0/vecttable.c index 3871a30055..7fd5c7fb8f 100644 --- a/core/cortex-m0/vecttable.c +++ b/core/cortex-m0/vecttable.c @@ -10,6 +10,7 @@ #include <stddef.h> #include <stdint.h> +#include "compiler.h" #include "config.h" #include "panic-internal.h" #include "task.h" @@ -66,10 +67,7 @@ extern void reset(void); /* Disable warning that "initializer overrides prior initialization of this * subobject", since we are explicitly doing this to handle the unused IRQs. */ -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Winitializer-overrides" -#endif /* __clang__ */ +DISABLE_CLANG_WARNING("-Winitializer-overrides") #define table(x) \ const func vectors[] __attribute__(( \ @@ -95,9 +93,7 @@ table(item(stack_end) item(reset) vec(nmi) vec(hard_fault) vec(mpu_fault) vec( irq(31)); #if PASS == 2 -#ifdef __clang__ -#pragma clang diagnostic pop -#endif /* __clang__ */ +ENABLE_CLANG_WARNING("-Winitializer-overrides") #endif #if PASS == 1 |