Am 13.05.2018 um 11:06 schrieb Stefan Weil:
> It now prevents compiler warnings (enabled with -Wimplicit-fallthrough=
> or -Wextra) as intended.
> 
> Signed-off-by: Stefan Weil <s...@weilnetz.de>
> ---
> 
> I suggest to add and use a similar macro QEMU_FALLTHROUGH()
> for the rest of the code and can provide a patch if that's
> fine for everyone.
> 
> Regards
> Stefan
> 
>  disas/libvixl/vixl/globals.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/disas/libvixl/vixl/globals.h b/disas/libvixl/vixl/globals.h
> index 61dc9f7f7e..33c4231d91 100644
> --- a/disas/libvixl/vixl/globals.h
> +++ b/disas/libvixl/vixl/globals.h
> @@ -112,6 +112,8 @@ inline void USE(T1, T2, T3, T4) {}
>  // C++11(201103L).
>  #if __has_warning("-Wimplicit-fallthrough") && __cplusplus >= 201103L
>    #define VIXL_FALLTHROUGH() [[clang::fallthrough]] //NOLINT
> +#elif defined(__GNUC__)
> +  #define VIXL_FALLTHROUGH() __attribute__((fallthrough))
>  #else
>    #define VIXL_FALLTHROUGH() do {} while (0)
>  #endif


Even with the above patch, disas/libvixl raises a compiler warning for a
fall through case. The patch below fixes that warning, but I am not sure
whether a fall through is correct there.

Stefan


diff --git a/disas/libvixl/vixl/a64/disasm-a64.cc
b/disas/libvixl/vixl/a64/disasm-a64.cc
index 7a58a5c087..5481d94209 100644
--- a/disas/libvixl/vixl/a64/disasm-a64.cc
+++ b/disas/libvixl/vixl/a64/disasm-a64.cc
@@ -2986,6 +2986,7 @@ int Disassembler::SubstituteImmediateField(const
Instruction* instr,
           return 3;
         }
       }
+      VIXL_FALLTHROUGH(); // ???
     }
     case 'C': {  // ICondB - Immediate Conditional Branch.
       int64_t offset = instr->ImmCondBranch() << 2;


Reply via email to