-Wimplicit-fallthrough broken?
Georg-Johann Lay
avr@gjlay.de
Fri Jul 21 17:40:00 GMT 2017
Mason schrieb:
> On 19/07/2017 22:18, Georg-Johann Lay wrote:
>
>> Hi, with the following small small test I am getting these warnings:
>>
>> void test1 (unsigned char c)
>> {
>> switch (c)
>> {
>> case 1: c++; // fallthrough
>> case 2: c--; // FALLTHRU
>> case 3: c++; // FALLTHROUGH
>> case 4: z = c; break;
>> }
>> }
>>
>> void test2 (unsigned char c)
>> {
>> switch (c)
>> {
>> case 1: c++;
>> /* fallthrough */
>> case 2: c--;
>> /* FALLTHRU */
>> case 3: c++;
>> /* FALLTHROUGH */
>> case 4: z = c; break;
>> }
>> }
>>
>>
>>
>> simple.c: In function 'test1':
>> simple.c:7:18: warning: this statement may fall through
>> [-Wimplicit-fallthrough=]
>> case 1: c++; // fallthrough
>> ~^~
>> simple.c:8:9: note: here
>> case 2: c--; // FALLTHRU
>> ^~~~
>> simple.c:8:18: warning: this statement may fall through
>> [-Wimplicit-fallthrough=]
>> case 2: c--; // FALLTHRU
>> ~^~
>> simple.c:9:9: note: here
>> case 3: c++; // FALLTHROUGH
>> ^~~~
>> simple.c:9:18: warning: this statement may fall through
>> [-Wimplicit-fallthrough=]
>> case 3: c++; // FALLTHROUGH
>> ~^~
>> simple.c:10:9: note: here
>> case 4: z = c; break;
>> ^~~~
>> simple.c: In function 'test2':
>> simple.c:18:18: warning: this statement may fall through
>> [-Wimplicit-fallthrough=]
>> case 1: c++;
>> ~^~
>> simple.c:20:9: note: here
>> case 2: c--;
>> ^~~~
>> simple.c:20:18: warning: this statement may fall through
>> [-Wimplicit-fallthrough=]
>> case 2: c--;
>> ~^~
>> simple.c:22:9: note: here
>> case 3: c++;
>> ^~~~
>> simple.c:22:18: warning: this statement may fall through
>> [-Wimplicit-fallthrough=]
>> case 3: c++;
>> ~^~
>> simple.c:24:9: note: here
>> case 4: z = c; break;
>> ^~~~
>>
>>
>> How do I have to formulate these comments? It's under mingw32, may that
>> be a problem?
>
> There are a few important pieces missing from your message.
>
> - The version of gcc you're using
trunk (future v8)
> - The exact command-line you used (flags, C vs C++ mode, etc)
gcc simple.c -S -W -save-temps
(cross compilation actually, but the target really should not matter)
> - What you expected vs what happened
I am expecting that the comments are silencing the warnings. What
actually happened can be admired above.
> You seem to be looking for a way to silence the warning for specific
> instances. Have a look here:
According to the documentation, these magic comments should work and
quiet the warnings.
Johann
More information about the Gcc-help
mailing list