switch fallthrough change

Corinna Vinschen corinna-cygwin@cygwin.com
Wed Aug 5 20:52:54 GMT 2020


Hi folks,

Just a small headsup here.

I introduced a change already in the Linux kernel for a couple of
months.  Rather than various comments /*FALLTHRU*/, /* fall through */,
etc., Cygwin is using a statement

  fallthrough;

at the end of a switch case intentionally falling through to the
next case branch.  This is using a GCC attribute under the hood,
__attribute__ ((__fallthrough__)) introduced with GCC 7.1.

The advantage is a better control of the way a switch case ends.
It now *has* to end with either one of

  break;
  fallthrough;
  goto <label>;
  return [expression];
  continue;

otherwise GCC complains.  For this I added -Wimplicit-fallthrough=5 to
our build flags.  Just by checking our switch statements I found a
couple of missing break statements as well as one or two missing
intentional fallthrough comments.

For now this only affects the cygwin dir, not the utils or cygserver
dirs, lacking a common header file for this purpose.  Patches welcome.


Corinna


More information about the Cygwin-developers mailing list