Cygwin: Add 'fallthrough' pseudo keyword for switch/case use

This patch has been inspired by the Linux kernel patch

  294f69e662d1 compiler_attributes.h: Add 'fallthrough' pseudo keyword for switch/case use

written by Joe Perches <joe AT perches DOT com> based on an idea from
Dan Carpenter <dan DOT carpenter AT oracle DOT com>.  The following text
is from the original log message:

Reserve the pseudo keyword 'fallthrough' for the ability to convert the
various case block /* fallthrough */ style comments to appear to be an
actual reserved word with the same gcc case block missing fallthrough
warning capability.

All switch/case blocks now should end in one of:

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

In C mode, GCC supports the __fallthrough__ attribute since 7.1,
the same time the warning and the comment parsing were introduced.

Cygwin-only: add an explicit -Wimplicit-fallthrough=5 to the build
flags.
This commit is contained in:
Corinna Vinschen
2020-08-05 21:58:22 +02:00
parent 5898a044c3
commit 50ad198085
33 changed files with 67 additions and 63 deletions

View File

@ -829,7 +829,7 @@ path_conv::check (const char *src, unsigned opt,
opt &= ~PC_SYM_FOLLOW;
sym.path_flags |= PATH_RESOLVE_PROCFD;
}
/*FALLTHRU*/
fallthrough;
case virt_symlink:
goto is_virtual_symlink;
case virt_pipe:
@ -866,7 +866,7 @@ path_conv::check (const char *src, unsigned opt,
| FILE_ATTRIBUTE_DEVICE;
goto out;
}
/*FALLTHRU*/
fallthrough;
case virt_chr:
if (component == 0)
fileattr = FILE_ATTRIBUTE_DEVICE;
@ -2021,7 +2021,7 @@ symlink_worker (const char *oldpath, path_conv &win32_newpath, bool isdevice)
}
/* Otherwise, fall back to default symlink type. */
wsym_type = WSYM_sysfile;
/*FALLTHRU*/
fallthrough;
case WSYM_sysfile:
if (win32_newpath.fs_flags () & FILE_SUPPORTS_REPARSE_POINTS)
{