From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Thomas Huth <thuth@redhat.com>,
Richard Henderson <rth@twiddle.net>,
qemu-devel@nongnu.org
Cc: Chen Qun <kuhn.chenqun@huawei.com>
Subject: Re: [PATCH] tcg/optimize: Add fallthrough annotations
Date: Thu, 29 Oct 2020 13:37:10 +0100 [thread overview]
Message-ID: <ffbb5d98-5a74-0f22-eda7-e25eb92c541e@redhat.com> (raw)
In-Reply-To: <20201029122833.195420-1-thuth@redhat.com>
On 10/29/20 1:28 PM, Thomas Huth wrote:
> 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.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
> tcg/optimize.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> diff --git a/tcg/optimize.c b/tcg/optimize.c
> index 220f4601d5..c2768c9770 100644
> --- a/tcg/optimize.c
> +++ b/tcg/optimize.c
> @@ -26,6 +26,12 @@
> #include "qemu/osdep.h"
> #include "tcg/tcg-op.h"
>
> +#if __has_attribute(fallthrough)
> +# define fallthrough() __attribute__((fallthrough))
> +#else
> +# define fallthrough() do {} while (0)
> +#endif
This looks something we can reuse, what about adding it
as QEMU_FALLTHROUGH in "qemu/compiler.h"?
> +
> #define CASE_OP_32_64(x) \
> glue(glue(case INDEX_op_, x), _i32): \
> glue(glue(case INDEX_op_, x), _i64)
> @@ -855,6 +861,7 @@ void tcg_optimize(TCGContext *s)
> if ((arg_info(op->args[1])->mask & 0x80) != 0) {
> break;
> }
> + fallthrough();
> CASE_OP_32_64(ext8u):
> mask = 0xff;
> goto and_const;
> @@ -862,6 +869,7 @@ void tcg_optimize(TCGContext *s)
> if ((arg_info(op->args[1])->mask & 0x8000) != 0) {
> break;
> }
> + fallthrough();
> CASE_OP_32_64(ext16u):
> mask = 0xffff;
> goto and_const;
> @@ -869,6 +877,7 @@ void tcg_optimize(TCGContext *s)
> if ((arg_info(op->args[1])->mask & 0x80000000) != 0) {
> break;
> }
> + fallthrough();
> case INDEX_op_ext32u_i64:
> mask = 0xffffffffU;
> goto and_const;
> @@ -886,6 +895,7 @@ void tcg_optimize(TCGContext *s)
> if ((arg_info(op->args[1])->mask & 0x80000000) != 0) {
> break;
> }
> + 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;
>
next prev parent reply other threads:[~2020-10-29 12:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-29 12:28 [PATCH] tcg/optimize: Add fallthrough annotations Thomas Huth
2020-10-29 12:37 ` Philippe Mathieu-Daudé [this message]
2020-10-29 20:07 ` Richard Henderson
2020-10-30 2:43 ` Chenqun (kuhn)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ffbb5d98-5a74-0f22-eda7-e25eb92c541e@redhat.com \
--to=philmd@redhat.com \
--cc=kuhn.chenqun@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).