> -----Original Message----- > From: Richard Henderson [mailto:richard.hender...@linaro.org] > Sent: Friday, October 30, 2020 4:07 AM > To: Thomas Huth <th...@redhat.com>; Richard Henderson <r...@twiddle.net>; > qemu-devel@nongnu.org > Cc: Chenqun (kuhn) <kuhn.chen...@huawei.com> > Subject: Re: [PATCH] tcg/optimize: Add fallthrough annotations > > On 10/29/20 5:28 AM, 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. > > Why would the macro matter? It expands to two case statements with > nothing in between them. > > This sounds like a compiler bug that should be reported. > Hi all, I have queried the GCC options description about the Wimplicit-fallthrough and verified it. The value of Wimplicit-fallthrough ranges from 0 to 5. The value 0 is to ignore all warnings, which is certainly not what we need. If the value is set to 1 or 2, most fall through on the QEMU can take effect. Eg:/* FALLTHRU */、/* fallthru */、/* fall-through */、/* FALLTHOUGH */、/* fall through */、/* fallthrough */..
When the value ranges from 3 to 5, more fallthrough comments become invalid as the value increases. So, I agree with Philippe's suggestion to add a QEMU_FALLTHROUGH to unify this compiler property. Thanks, Chen Qun Additional gcc information is as follows: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html -Wimplicit-fallthrough is the same as -Wimplicit-fallthrough=3 and -Wno-implicit-fallthrough is the same as -Wimplicit-fallthrough=0. The option argument n specifies what kind of comments are accepted: -Wimplicit-fallthrough=0 disables the warning altogether. -Wimplicit-fallthrough=1 matches .* regular expression, any comment is used as fallthrough comment. -Wimplicit-fallthrough=2 case insensitively matches .*falls?[ \t-]*thr(ough|u).* regular expression. -Wimplicit-fallthrough=3 case sensitively matches one of the following regular expressions: -fallthrough @fallthrough@ lint -fallthrough[ \t]* [ \t.!]*(ELSE,? |INTENTIONAL(LY)? )? FALL(S | |-)?THR(OUGH|U)[ \t.!]*(-[^\n\r]*)? [ \t.!]*(Else,? |Intentional(ly)? )? Fall((s | |-)[Tt]|t)hr(ough|u)[ \t.!]*(-[^\n\r]*)? [ \t.!]*([Ee]lse,? |[Ii]ntentional(ly)? )? fall(s | |-)?thr(ough|u)[ \t.!]*(-[^\n\r]*)? -Wimplicit-fallthrough=4 case sensitively matches one of the following regular expressions: -fallthrough @fallthrough@ lint -fallthrough[ \t]* [ \t]*FALLTHR(OUGH|U)[ \t]* -Wimplicit-fallthrough=5 doesn’t recognize any comments as fallthrough comments, only attributes disable the warning.