aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/libc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2020-08-05 21:58:22 +0200
committerCorinna Vinschen <corinna@vinschen.de>2020-08-05 21:58:22 +0200
commit50ad1980858b1092ebdd8c3dd6ae14d72596eb4d (patch)
tree1cf5f09b7554eed30007067719022243a440e4e5 /winsup/cygwin/libc
parent5898a044c32cf67a1fdc90c8ba48c166d2b11909 (diff)
downloadnewlib-50ad1980858b1092ebdd8c3dd6ae14d72596eb4d.zip
newlib-50ad1980858b1092ebdd8c3dd6ae14d72596eb4d.tar.gz
newlib-50ad1980858b1092ebdd8c3dd6ae14d72596eb4d.tar.bz2
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.
Diffstat (limited to 'winsup/cygwin/libc')
-rw-r--r--winsup/cygwin/libc/base64.c2
-rw-r--r--winsup/cygwin/libc/fnmatch.c2
-rw-r--r--winsup/cygwin/libc/ftw.c2
-rw-r--r--winsup/cygwin/libc/msgcat.c3
-rw-r--r--winsup/cygwin/libc/nftw.c2
-rw-r--r--winsup/cygwin/libc/rexec.cc2
-rw-r--r--winsup/cygwin/libc/strptime.cc4
7 files changed, 9 insertions, 8 deletions
diff --git a/winsup/cygwin/libc/base64.c b/winsup/cygwin/libc/base64.c
index 02cb46d..03c1575 100644
--- a/winsup/cygwin/libc/base64.c
+++ b/winsup/cygwin/libc/base64.c
@@ -282,7 +282,7 @@ b64_pton(char const *src, unsigned char *target, size_t targsize)
return (-1);
ch = *src++; /* Skip the = */
/* Fall through to "single trailing =" case. */
- /* FALLTHROUGH */
+ fallthrough;
case 3: /* Valid, means two bytes of info */
/*
diff --git a/winsup/cygwin/libc/fnmatch.c b/winsup/cygwin/libc/fnmatch.c
index fc43765..6655bca 100644
--- a/winsup/cygwin/libc/fnmatch.c
+++ b/winsup/cygwin/libc/fnmatch.c
@@ -193,7 +193,7 @@ fnmatch1(const char *pattern, const char *string, const char *stringstart,
return (FNM_NOMATCH);
pattern += pclen;
}
- /* FALLTHROUGH */
+ fallthrough;
default:
norm:
string += sclen;
diff --git a/winsup/cygwin/libc/ftw.c b/winsup/cygwin/libc/ftw.c
index 61d1e7c..7a320d3 100644
--- a/winsup/cygwin/libc/ftw.c
+++ b/winsup/cygwin/libc/ftw.c
@@ -88,7 +88,7 @@ ftw(const char *path, int (*fn)(const char *, const struct stat *, int),
break;
case FTS_DC:
errno = ELOOP;
- /* FALLTHROUGH */
+ fallthrough;
default:
error = -1;
goto done;
diff --git a/winsup/cygwin/libc/msgcat.c b/winsup/cygwin/libc/msgcat.c
index 3df43af..cdbb4ae 100644
--- a/winsup/cygwin/libc/msgcat.c
+++ b/winsup/cygwin/libc/msgcat.c
@@ -81,6 +81,7 @@ static pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER;
#else
#include "../locale/setlocale.h"
+#include "winsup.h"
#define SIZE_T_MAX __SIZE_MAX__
#define _close close
#define _open open
@@ -233,7 +234,7 @@ catopen(const char *name, int type)
break;
case '%':
++nlspath;
- /* FALLTHROUGH */
+ fallthrough;
default:
if (pathP - path >=
sizeof(path) - 1)
diff --git a/winsup/cygwin/libc/nftw.c b/winsup/cygwin/libc/nftw.c
index 1def241..f54dadf 100644
--- a/winsup/cygwin/libc/nftw.c
+++ b/winsup/cygwin/libc/nftw.c
@@ -105,7 +105,7 @@ nftw(const char *path, int (*fn)(const char *, const struct stat *, int,
break;
case FTS_DC:
errno = ELOOP;
- /* FALLTHROUGH */
+ fallthrough;
default:
error = -1;
goto done;
diff --git a/winsup/cygwin/libc/rexec.cc b/winsup/cygwin/libc/rexec.cc
index a9d0048..7f25123 100644
--- a/winsup/cygwin/libc/rexec.cc
+++ b/winsup/cygwin/libc/rexec.cc
@@ -179,7 +179,7 @@ next:
case DEFAULT:
usedefault = 1;
- /* FALL THROUGH */
+ fallthrough;
case MACH:
if (!usedefault) {
diff --git a/winsup/cygwin/libc/strptime.cc b/winsup/cygwin/libc/strptime.cc
index cbb3e0c..3a9bdbb 100644
--- a/winsup/cygwin/libc/strptime.cc
+++ b/winsup/cygwin/libc/strptime.cc
@@ -524,7 +524,7 @@ literal:
case 'k': /* The hour (24-hour clock representation). */
LEGAL_ALT(0);
- /* FALLTHROUGH */
+ fallthrough;
case 'H':
LEGAL_ALT(ALT_O);
bp = conv_num(bp, &tm->tm_hour, 0, 23, ALT_DIGITS);
@@ -532,7 +532,7 @@ literal:
case 'l': /* The hour (12-hour clock representation). */
LEGAL_ALT(0);
- /* FALLTHROUGH */
+ fallthrough;
case 'I':
LEGAL_ALT(ALT_O);
bp = conv_num(bp, &tm->tm_hour, 1, 12, ALT_DIGITS);