1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-29 16:31:18 +01:00

Merge pull request #18868 from maribu/tests/mpu_stack_guard

tests/mpu_stack_guard: Fix compilation on modern GCC (>= 12.x)
This commit is contained in:
Marian Buschsieweke 2022-11-10 14:49:27 +01:00 committed by GitHub
commit a17ae056bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,6 +38,16 @@ static struct {
char stack[THREAD_STACKSIZE_MAIN];
} buf;
/* Tell modern GCC (12.x) to not complain that this infinite recursion is
* bound to overflow the stack - this is exactly what this test wants to do :)
*
* Also, tell older versions of GCC that do not know about -Winfinit-recursion
* that it is safe to ignore `GCC diagnostics ignored "-Winfinit-recursion"`.
* They behave as intended in this case :)
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpragmas"
#pragma GCC diagnostic ignored "-Winfinite-recursion"
static int recurse(int counter)
{
printf("counter =%4d, SP = 0x%08x, canary = 0x%08x\n", counter, (unsigned int)__get_PSP(), buf.canary);
@ -55,6 +65,7 @@ static int recurse(int counter)
/* Recursing twice here prevents the compiler from optimizing-out the recursion. */
return recurse(counter) + recurse(counter);
}
#pragma GCC diagnostic pop
static void *thread(void *arg)
{