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

@@ -381,27 +381,27 @@ pg_ent::getent (void)
{
case rewound:
state = from_cache;
/*FALLTHRU*/
fallthrough;
case from_cache:
if (nss_db_enum_caches ()
&& (entry = enumerate_caches ()))
return entry;
state = from_file;
/*FALLTHRU*/
fallthrough;
case from_file:
if (from_files
&& nss_db_enum_files ()
&& (entry = enumerate_file ()))
return entry;
state = from_builtin;
/*FALLTHRU*/
fallthrough;
case from_builtin:
if (from_db
&& nss_db_enum_builtin ()
&& (entry = enumerate_builtin ()))
return entry;
state = from_local;
/*FALLTHRU*/
fallthrough;
case from_local:
if (from_db
&& nss_db_enum_local ()
@@ -410,7 +410,7 @@ pg_ent::getent (void)
&& (entry = enumerate_local ()))
return entry;
state = from_sam;
/*FALLTHRU*/
fallthrough;
case from_sam:
if (from_db
&& nss_db_enum_local ()
@@ -422,14 +422,14 @@ pg_ent::getent (void)
&& (entry = enumerate_sam ()))
return entry;
state = from_ad;
/*FALLTHRU*/
fallthrough;
case from_ad:
if (cygheap->dom.member_machine ()
&& from_db
&& (entry = enumerate_ad ()))
return entry;
state = finished;
/*FALLTHRU*/
fallthrough;
case finished:
break;
}
@@ -673,7 +673,7 @@ pw_ent::enumerate_caches ()
}
cnt = 0;
max = 1;
/*FALLTHRU*/
fallthrough;
case 1:
if (from_files)
{
@@ -684,7 +684,7 @@ pw_ent::enumerate_caches ()
}
cnt = 0;
max = 2;
/*FALLTHRU*/
fallthrough;
default:
if (from_db)
{