rp2040: Suppress spurious gcc v12 array bounds warning

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2022-09-29 11:03:22 -04:00
parent 34870d3e2a
commit 6288da13ac
1 changed files with 13 additions and 3 deletions

View File

@ -15,13 +15,23 @@
// to (especially for the flash functions) call while the XIP layer
// is unavailable.
static __always_inline void *rom_hword_as_ptr(uint16_t rom_address) {
#if defined(__GNUC__) && (__GNUC__ >= 12)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
return (void *)(uintptr_t)*(uint16_t *)(uintptr_t)rom_address;
#pragma GCC diagnostic pop
#else
return (void *)(uintptr_t)*(uint16_t *)(uintptr_t)rom_address;
#endif
}
static void * _ramfunc
rom_func_lookup(uint32_t code)
{
// Table and lookup function are provided by the BOOTROM
void *(*fn)(uint16_t *, uint32_t) =
(void *)(uintptr_t)(*(uint16_t *)0x18);
uint16_t *table = (uint16_t *)(uintptr_t)(*(uint16_t *)0x14);
void *(*fn)(uint16_t *, uint32_t) = rom_hword_as_ptr(0x18);
uint16_t *table = rom_hword_as_ptr(0x14);
return fn(table, code);
}