From 118df55bc3f40b7c8ce7c9a4f964204246ab2df9 Mon Sep 17 00:00:00 2001 From: Alexandre Duret-Lutz Date: Wed, 29 Apr 2020 23:04:51 +0200 Subject: [PATCH] [buddy] workaround newer clang warning It seems clang now warn about fallthrough case statements in C, but ignore any /* fall through */ comment if that comes from a macro. * src/bddop.c: Use the fallthrough attribute if available. --- buddy/src/bddop.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/buddy/src/bddop.c b/buddy/src/bddop.c index 7adaea55b..afd2ce266 100644 --- a/buddy/src/bddop.c +++ b/buddy/src/bddop.c @@ -42,6 +42,15 @@ #include "kernel.h" #include "cache.h" +#ifdef __has_attribute +# if __has_attribute(fallthrough) +# define BUDDY_FALLTHROUGH __attribute__ ((fallthrough)) +# endif +#endif +#ifndef BUDDY_FALLTHROUGH +# define BUDDY_FALLTHROUGH while (0); +#endif + /* Hash value modifiers to distinguish between entries in misccache */ #define CACHEID_CONSTRAIN 0x0 #define CACHEID_RESTRICT 0x1 @@ -640,7 +649,7 @@ static BDD apply_rec(BDD l, BDD r) r = tmp; \ op = bddop_imp; \ } \ - /* fall through */ \ + BUDDY_FALLTHROUGH; \ case bddop_imp: \ if (ISONE(r) || ISZERO(l)) \ return 1; \ @@ -666,7 +675,7 @@ static BDD apply_rec(BDD l, BDD r) r = tmp; \ op = bddop_diff; \ } \ - /* fall through */ \ + BUDDY_FALLTHROUGH; \ case bddop_diff: /* l - r = l &! r */ \ if (l == r || ISONE(r)) \ return 0; \ -- GitLab