mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-03-27 13:45:07 +00:00
tcg/optimize: Add fallthrough annotations
To be able to compile this file with -Werror=implicit-fallthrough, we need to add some fallthrough annotations to the case statements that might fall through. Unfortunately, the typical "/* fallthrough */" comments do not work here as expected since some case labels are wrapped in macros and the compiler fails to match the comments in this case. But using __attribute__((fallthrough)) seems to work fine, so let's use that instead (by introducing a new QEMU_FALLTHROUGH macro in our compiler.h header file). Backports d84568b773fe1fc469c4d8419c3545be52eec82c
This commit is contained in:
parent
782e912c98
commit
6a22a7b80e
|
@ -277,4 +277,15 @@ static union MSVC_FLOAT_HACK __NAN = {{0x00, 0x00, 0xC0, 0x7F}};
|
|||
|
||||
#endif // _MSC_VER
|
||||
|
||||
/**
|
||||
* In most cases, normal "fallthrough" comments are good enough for
|
||||
* switch-case statements, but sometimes the compiler has problems
|
||||
* with those. In that case you can use QEMU_FALLTHROUGH instead.
|
||||
*/
|
||||
#if __has_attribute(fallthrough)
|
||||
# define QEMU_FALLTHROUGH __attribute__((fallthrough))
|
||||
#else
|
||||
# define QEMU_FALLTHROUGH do {} while (0) /* fallthrough */
|
||||
#endif
|
||||
|
||||
#endif /* COMPILER_H */
|
||||
|
|
|
@ -856,6 +856,7 @@ void tcg_optimize(TCGContext *s)
|
|||
if ((arg_info(op->args[1])->mask & 0x80) != 0) {
|
||||
break;
|
||||
}
|
||||
QEMU_FALLTHROUGH;
|
||||
CASE_OP_32_64(ext8u):
|
||||
mask = 0xff;
|
||||
goto and_const;
|
||||
|
@ -863,6 +864,7 @@ void tcg_optimize(TCGContext *s)
|
|||
if ((arg_info(op->args[1])->mask & 0x8000) != 0) {
|
||||
break;
|
||||
}
|
||||
QEMU_FALLTHROUGH;
|
||||
CASE_OP_32_64(ext16u):
|
||||
mask = 0xffff;
|
||||
goto and_const;
|
||||
|
@ -870,6 +872,7 @@ void tcg_optimize(TCGContext *s)
|
|||
if ((arg_info(op->args[1])->mask & 0x80000000) != 0) {
|
||||
break;
|
||||
}
|
||||
QEMU_FALLTHROUGH;
|
||||
case INDEX_op_ext32u_i64:
|
||||
mask = 0xffffffffU;
|
||||
goto and_const;
|
||||
|
@ -887,6 +890,7 @@ void tcg_optimize(TCGContext *s)
|
|||
if ((arg_info(op->args[1])->mask & 0x80000000) != 0) {
|
||||
break;
|
||||
}
|
||||
QEMU_FALLTHROUGH;
|
||||
case INDEX_op_extu_i32_i64:
|
||||
/* We do not compute affected as it is a size changing op. */
|
||||
mask = (uint32_t)arg_info(op->args[1])->mask;
|
||||
|
|
Loading…
Reference in a new issue