public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/100605] New: -Wimplicit-fallthrough=5 still recognizes comments
@ 2021-05-14 15:31 tuliom at ascii dot art.br
  2021-05-14 15:55 ` [Bug c/100605] " tuliom at ascii dot art.br
  2021-05-17  7:58 ` marxin at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: tuliom at ascii dot art.br @ 2021-05-14 15:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100605

            Bug ID: 100605
           Summary: -Wimplicit-fallthrough=5 still recognizes comments
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tuliom at ascii dot art.br
  Target Milestone: ---

According to the GCC manual:

"-Wimplicit-fallthrough=5 doesn’t recognize any comments as fallthrough
comments, only attributes disable the warning."

However, comments are still being recognized and are disabling the warning.
In the following example, there are 3 fall-throughs:

$ cat t.c
#include <stddef.h>
#include <inttypes.h>

uint32_t foo(size_t in)
{
  uint32_t out = 0;
  uint32_t k = 0;

  switch (in & 3)
    {
    case 3:
      k = 3;
      // FALLTHROUGH
    case 2:
      k = 8;
    case 1:
      k = 16;
    case 0:
    default:
      out = k;
      break;
    }

  return out;
}

However, GCC 11 reports only 2 when using -Wimplicit-fallthrough=5:

$ gcc-11 -c -Wimplicit-fallthrough=5 -Werror=implicit-fallthrough t.c
t.c: In function ‘foo’:
t.c:15:9: error: this statement may fall through
[-Werror=implicit-fallthrough=]
   15 |       k = 8;
      |       ~~^~~
t.c:16:5: note: here
   16 |     case 1:
      |     ^~~~
t.c:17:9: error: this statement may fall through
[-Werror=implicit-fallthrough=]
   17 |       k = 16;
      |       ~~^~~~
t.c:18:5: note: here
   18 |     case 0:
      |     ^~~~
cc1: some warnings being treated as errors

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/100605] -Wimplicit-fallthrough=5 still recognizes comments
  2021-05-14 15:31 [Bug c/100605] New: -Wimplicit-fallthrough=5 still recognizes comments tuliom at ascii dot art.br
@ 2021-05-14 15:55 ` tuliom at ascii dot art.br
  2021-05-17  7:58 ` marxin at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: tuliom at ascii dot art.br @ 2021-05-14 15:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100605

--- Comment #1 from Tulio Magno Quites Machado Filho <tuliom at ascii dot art.br> ---
Interestingly, all the 3 warnings are reported when using -save-temps:

$ gcc -c -save-temps -Wimplicit-fallthrough=5 -Werror=implicit-fallthrough t.c 
t.c: In function ‘foo’:
t.c:12:9: error: this statement may fall through
[-Werror=implicit-fallthrough=]
   12 |       k = 3;
      |       ~~^~~
t.c:14:5: note: here
   14 |     case 2:
      |     ^~~~
t.c:15:9: error: this statement may fall through
[-Werror=implicit-fallthrough=]
   15 |       k = 8;
      |       ~~^~~
t.c:16:5: note: here
   16 |     case 1:
      |     ^~~~
t.c:17:9: error: this statement may fall through
[-Werror=implicit-fallthrough=]
   17 |       k = 16;
      |       ~~^~~~
t.c:18:5: note: here
   18 |     case 0:
      |     ^~~~
cc1: some warnings being treated as errors

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug c/100605] -Wimplicit-fallthrough=5 still recognizes comments
  2021-05-14 15:31 [Bug c/100605] New: -Wimplicit-fallthrough=5 still recognizes comments tuliom at ascii dot art.br
  2021-05-14 15:55 ` [Bug c/100605] " tuliom at ascii dot art.br
@ 2021-05-17  7:58 ` marxin at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-05-17  7:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100605

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Tulio Magno Quites Machado Filho from comment #1)
> Interestingly, all the 3 warnings are reported when using -save-temps:

That's because comments are lost when using -save-temps in .i pre-processed
source file.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-17  7:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14 15:31 [Bug c/100605] New: -Wimplicit-fallthrough=5 still recognizes comments tuliom at ascii dot art.br
2021-05-14 15:55 ` [Bug c/100605] " tuliom at ascii dot art.br
2021-05-17  7:58 ` marxin at gcc dot gnu.org

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 read-only IMAP folder(s) and NNTP newsgroup(s).