public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: Add 'fallthrough' pseudo keyword for switch/case use
@ 2020-08-05 20:43 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2020-08-05 20:43 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=50ad1980858b1092ebdd8c3dd6ae14d72596eb4d

commit 50ad1980858b1092ebdd8c3dd6ae14d72596eb4d
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Wed Aug 5 21:58:22 2020 +0200

    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.

Diff:
---
 winsup/cygwin/Makefile.in         |  2 +-
 winsup/cygwin/aio.cc              |  4 ++--
 winsup/cygwin/dcrt0.cc            |  4 ++--
 winsup/cygwin/exceptions.cc       |  2 +-
 winsup/cygwin/fhandler.cc         |  3 ++-
 winsup/cygwin/fhandler_dsp.cc     |  2 +-
 winsup/cygwin/fhandler_serial.cc  |  2 +-
 winsup/cygwin/fhandler_socket.cc  |  2 +-
 winsup/cygwin/fhandler_termios.cc |  2 +-
 winsup/cygwin/fhandler_tty.cc     |  4 ++--
 winsup/cygwin/fhandler_windows.cc |  2 +-
 winsup/cygwin/glob.cc             |  2 +-
 winsup/cygwin/grp.cc              |  4 ++--
 winsup/cygwin/libc/base64.c       |  2 +-
 winsup/cygwin/libc/fnmatch.c      |  2 +-
 winsup/cygwin/libc/ftw.c          |  2 +-
 winsup/cygwin/libc/msgcat.c       |  3 ++-
 winsup/cygwin/libc/nftw.c         |  2 +-
 winsup/cygwin/libc/rexec.cc       |  2 +-
 winsup/cygwin/libc/strptime.cc    |  4 ++--
 winsup/cygwin/passwd.cc           | 18 +++++++++---------
 winsup/cygwin/path.cc             |  6 +++---
 winsup/cygwin/posix_ipc.cc        |  4 ++--
 winsup/cygwin/quotactl.cc         |  4 ++--
 winsup/cygwin/regex/regcomp.c     |  6 +++---
 winsup/cygwin/sec_acl.cc          |  2 +-
 winsup/cygwin/sec_posixacl.cc     |  2 +-
 winsup/cygwin/select.cc           |  4 ++--
 winsup/cygwin/sigproc.cc          |  8 ++++----
 winsup/cygwin/smallprint.cc       | 16 ++++++++--------
 winsup/cygwin/termios.cc          |  2 +-
 winsup/cygwin/uinfo.cc            |  4 ++--
 winsup/cygwin/winsup.h            |  2 ++
 33 files changed, 67 insertions(+), 63 deletions(-)

diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index 9bbdf8cc3..fac81759e 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -73,7 +73,7 @@ CRT0:=$(cygwin_build)/crt0.o
 #
 MT_SAFE:=@MT_SAFE@
 CCEXTRA=
-COMMON_CFLAGS=-MMD ${$(*F)_CFLAGS} -Werror -fmerge-constants -ftracer $(CCEXTRA)
+COMMON_CFLAGS=-MMD ${$(*F)_CFLAGS} -Wimplicit-fallthrough=5 -Werror -fmerge-constants -ftracer $(CCEXTRA)
 ifeq ($(target_cpu),x86_64)
 COMMON_CFLAGS+=-mcmodel=small
 endif
diff --git a/winsup/cygwin/aio.cc b/winsup/cygwin/aio.cc
index 619dbdcb7..4d1c2ee45 100644
--- a/winsup/cygwin/aio.cc
+++ b/winsup/cygwin/aio.cc
@@ -698,7 +698,7 @@ aio_read (struct aiocb *aio)
         if (slot >= 0)
           debug_printf ("slot %d released", slot);
       }
-      /* fall through */
+      fallthrough;
 
     case ENOBUFS:
       aio->aio_errno = EINPROGRESS;
@@ -888,7 +888,7 @@ aio_write (struct aiocb *aio)
         if (slot >= 0)
           debug_printf ("slot %d released", slot);
       }
-      /* fall through */
+      fallthrough;
 
     case ENOBUFS:
       aio->aio_errno = EINPROGRESS;
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 5d8b4b74e..810017956 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -551,7 +551,7 @@ get_cygwin_startup_info ()
 	  case _CH_FORK:
 	    in_forkee = true;
 	    should_be_cb = sizeof (child_info_fork);
-	    /* fall through */;
+	    fallthrough;
 	  case _CH_SPAWN:
 	  case _CH_EXEC:
 	    if (!should_be_cb)
@@ -570,7 +570,7 @@ get_cygwin_startup_info ()
 	    break;
 	  default:
 	    system_printf ("unknown exec type %u", res->type);
-	    /* intentionally fall through */
+	    fallthrough;
 	  case _CH_WHOOPS:
 	    res = NULL;
 	    break;
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index bccedfa5d..0d9e8f70e 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -741,7 +741,7 @@ exception::handle (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in,
 	 Linux behaviour and also makes a lot of sense on Windows. */
       if (me.altstack.ss_flags)
 	global_sigs[SIGSEGV].sa_handler = SIG_DFL;
-      /*FALLTHRU*/
+      fallthrough;
     case STATUS_ARRAY_BOUNDS_EXCEEDED:
     case STATUS_IN_PAGE_ERROR:
     case STATUS_NO_MEMORY:
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 9d6271b3d..82b21aff4 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -255,7 +255,7 @@ retry:
 		  break;
 		}
 	    }
-	  /*FALLTHRU*/
+	  fallthrough;
 	case STATUS_INVALID_DEVICE_REQUEST:
 	case STATUS_INVALID_PARAMETER:
 	case STATUS_INVALID_HANDLE:
@@ -265,6 +265,7 @@ retry:
 	      len = (size_t) -1;
 	      break;
 	    }
+	  fallthrough;
 	default:
 	  __seterrno_from_nt_status (status);
 	  len = (size_t) -1;
diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc
index b5c685bf8..e105514cb 100644
--- a/winsup/cygwin/fhandler_dsp.cc
+++ b/winsup/cygwin/fhandler_dsp.cc
@@ -1067,7 +1067,7 @@ fhandler_dev_dsp::open (int flags, mode_t)
     case O_RDWR:
       if ((num_in = waveInGetNumDevs ()) == 0)
 	err = ENXIO;
-      /* Fall through */
+      fallthrough;
     case O_WRONLY:
       if ((num_out = waveOutGetNumDevs ()) == 0)
 	err = ENXIO;
diff --git a/winsup/cygwin/fhandler_serial.cc b/winsup/cygwin/fhandler_serial.cc
index 1aaeedf1f..fd5b45899 100644
--- a/winsup/cygwin/fhandler_serial.cc
+++ b/winsup/cygwin/fhandler_serial.cc
@@ -103,7 +103,7 @@ fhandler_serial::raw_read (void *ptr, size_t& ulen)
 		default: /* Handle an error case from cygwait basically like
 			    a cancel condition and see if we got "something" */
 		  CancelIo (get_handle ());
-		  /*FALLTHRU*/
+		  fallthrough;
 		case WAIT_OBJECT_0:
 		  if (!GetOverlappedResult (get_handle (), &ov, &read_bytes,
 					    TRUE))
diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc
index 9f33d8087..f22412650 100644
--- a/winsup/cygwin/fhandler_socket.cc
+++ b/winsup/cygwin/fhandler_socket.cc
@@ -140,7 +140,7 @@ fhandler_socket::ioctl (unsigned int cmd, void *p)
     case OLD_SIOCGIFMTU:
     case OLD_SIOCGIFINDEX:
       cmd = CONV_OLD_TO_NEW_SIO (cmd);
-      /*FALLTHRU*/
+      fallthrough;
     case SIOCGIFFLAGS:
     case SIOCGIFBRDADDR:
     case SIOCGIFNETMASK:
diff --git a/winsup/cygwin/fhandler_termios.cc b/winsup/cygwin/fhandler_termios.cc
index ac1d5bd5c..36bc6255f 100644
--- a/winsup/cygwin/fhandler_termios.cc
+++ b/winsup/cygwin/fhandler_termios.cc
@@ -92,7 +92,7 @@ fhandler_termios::tcsetpgrp (const pid_t pgid)
 	  if (_my_tls.call_signal_handler ())
 	    continue;
 	  set_errno (EINTR);
-	  /* fall through intentionally */
+	  fallthrough;
 	default:
 	  res = -1;
 	  break;
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 6a004f3a5..92449ad7e 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -1550,7 +1550,7 @@ fhandler_pty_slave::write (const void *ptr, size_t len)
 	{
 	case ERROR_NO_DATA:
 	  err = ERROR_IO_DEVICE;
-	  /*FALLTHRU*/
+	  fallthrough;
 	default:
 	  __seterrno_from_win_error (err);
 	}
@@ -2163,7 +2163,7 @@ fhandler_pty_slave::facl (int cmd, int nentries, aclent_t *aclbufp)
 	    set_errno (EFAULT);
 	    break;
 	  }
-	/*FALLTHRU*/
+	fallthrough;
       case GETACLCNT:
 	if (!input_available_event)
 	  {
diff --git a/winsup/cygwin/fhandler_windows.cc b/winsup/cygwin/fhandler_windows.cc
index c9ef66c0b..3a2119fdd 100644
--- a/winsup/cygwin/fhandler_windows.cc
+++ b/winsup/cygwin/fhandler_windows.cc
@@ -112,7 +112,7 @@ fhandler_windows::read (void *buf, size_t& len)
 	      pthread::static_cancel_self ();
 	      break;
 	    }
-	  /*FALLTHRU*/
+	  fallthrough;
 	case WAIT_OBJECT_0 + 2:
 	  if (!PeekMessageW (ptr, hWnd_, 0, 0, PM_REMOVE))
 	    {
diff --git a/winsup/cygwin/glob.cc b/winsup/cygwin/glob.cc
index b61436de1..b0d393f98 100644
--- a/winsup/cygwin/glob.cc
+++ b/winsup/cygwin/glob.cc
@@ -347,7 +347,7 @@ globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv, size_t *l
 			    i--;
 			    break;
 			}
-			/* FALLTHROUGH */
+			fallthrough;
 		case COMMA:
 			if (i && *pm == COMMA)
 				break;
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index 5ec927fef..23e2d0251 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -404,7 +404,7 @@ gr_ent::enumerate_caches ()
 	}
       cnt = 0;
       max = 1;
-      /*FALLTHRU*/
+      fallthrough;
     case 1:
       if (from_files)
 	{
@@ -415,7 +415,7 @@ gr_ent::enumerate_caches ()
 	}
       cnt = 0;
       max = 2;
-      /*FALLTHRU*/
+      fallthrough;
     case 2:
       if (from_db)
 	{
diff --git a/winsup/cygwin/libc/base64.c b/winsup/cygwin/libc/base64.c
index 02cb46d41..03c15753a 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 fc4376510..6655bca88 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 61d1e7c21..7a320d3e2 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 3df43afa4..cdbb4ae44 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 1def24160..f54dadf9e 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 a9d0048d3..7f25123a0 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 cbb3e0ce9..3a9bdbb30 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);
diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc
index 0be94bcb2..1d6757b37 100644
--- a/winsup/cygwin/passwd.cc
+++ b/winsup/cygwin/passwd.cc
@@ -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)
 	{
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 36aa8278f..f3b9913bd 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -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)
 	    {
diff --git a/winsup/cygwin/posix_ipc.cc b/winsup/cygwin/posix_ipc.cc
index 86734c96a..eec9ffe63 100644
--- a/winsup/cygwin/posix_ipc.cc
+++ b/winsup/cygwin/posix_ipc.cc
@@ -221,7 +221,7 @@ restart1:
     case WAIT_OBJECT_0 + 2:
       if (timer_idx != 2)
 	pthread::static_cancel_self ();
-      /*FALLTHRU*/
+      fallthrough;
     case WAIT_OBJECT_0 + 3:
       ret = ETIMEDOUT;
       break;
@@ -249,7 +249,7 @@ restart1:
 	case WAIT_OBJECT_0 + 2:
 	  if (timer_idx != 2)
 	    pthread_testcancel ();
-	  /*FALLTHRU*/
+	  fallthrough;
 	case WAIT_OBJECT_0 + 3:
 	  ret = ETIMEDOUT;
 	  break;
diff --git a/winsup/cygwin/quotactl.cc b/winsup/cygwin/quotactl.cc
index 1e54a3a7a..f98a32d0b 100644
--- a/winsup/cygwin/quotactl.cc
+++ b/winsup/cygwin/quotactl.cc
@@ -58,7 +58,7 @@ quotactl (int cmd, const char *special, int id, caddr_t addr)
 	  set_errno (EINVAL);
 	  return -1;
 	}
-      /*FALLTHRU*/
+      fallthrough;
     case Q_QUOTAOFF:
     case Q_SETINFO:
       access |= FILE_WRITE_DATA;
@@ -68,7 +68,7 @@ quotactl (int cmd, const char *special, int id, caddr_t addr)
       break;
     case Q_SETQUOTA:
       access |= FILE_WRITE_DATA;
-      /*FALLTHRU*/
+      fallthrough;
     case Q_GETQUOTA:
       /* Windows feature: Default limits.  Get or set them with id == -1. */
       if (id != -1)
diff --git a/winsup/cygwin/regex/regcomp.c b/winsup/cygwin/regex/regcomp.c
index e99ee8cb4..a377e56fa 100644
--- a/winsup/cygwin/regex/regcomp.c
+++ b/winsup/cygwin/regex/regcomp.c
@@ -445,7 +445,7 @@ p_ere_exp(struct parse *p)
 		break;
 	case '{':		/* okay as ordinary except if digit follows */
 		(void)REQUIRE(!MORE() || !isdigit((uch)PEEK()), REG_BADRPT);
-		/* FALLTHROUGH */
+		fallthrough;
 	default:
 		p->next--;
 		wc = WGETNEXT();
@@ -656,7 +656,7 @@ p_simp_re(struct parse *p,
 		break;
 	case '*':
 		(void)REQUIRE(starordinary, REG_BADRPT);
-		/* FALLTHROUGH */
+		fallthrough;
 	default:
 		p->next--;
 		wc = WGETNEXT();
@@ -1545,7 +1545,7 @@ findmust(struct parse *p, struct re_guts *g)
 					return;
 				}
 			} while (OP(s) != O_QUEST && OP(s) != O_CH);
-			/* FALLTHROUGH */
+			fallthrough;
 		case OBOW:		/* things that break a sequence */
 		case OEOW:
 		case OBOL:
diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc
index 67749d7b1..fe015728d 100644
--- a/winsup/cygwin/sec_acl.cc
+++ b/winsup/cygwin/sec_acl.cc
@@ -1427,7 +1427,7 @@ __aclcalcmask (aclent_t *aclbufp, int nentries)
       case USER:
       case GROUP:
 	need_mask = true;
-	/*FALLTHRU*/
+	fallthrough;
       case GROUP_OBJ:
 	mask |= aclbufp[idx].a_perm;
 	break;
diff --git a/winsup/cygwin/sec_posixacl.cc b/winsup/cygwin/sec_posixacl.cc
index 6345220f3..e745bdb97 100644
--- a/winsup/cygwin/sec_posixacl.cc
+++ b/winsup/cygwin/sec_posixacl.cc
@@ -453,7 +453,7 @@ acl_set_tag_type (acl_entry_t entry_d, acl_tag_t tag_type)
 	  case ACL_MASK:
 	  case ACL_OTHER:
 	    acl->entry[idx].a_id = ACL_UNDEFINED_ID;
-	    /*FALLTHRU*/
+	    fallthrough;
 	  case ACL_USER:
 	  case ACL_GROUP:
 	    acl->entry[idx].a_type = tag_type;
diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc
index 43f07af43..4a8f3b2ec 100644
--- a/winsup/cygwin/select.cc
+++ b/winsup/cygwin/select.cc
@@ -469,7 +469,7 @@ was_timeout:
 	  pthread::static_cancel_self ();
 	  /*NOTREACHED*/
 	}
-      /*FALLTHRU*/
+      fallthrough;
     default:
       /* Timer event? */
       if (wait_ret == timer_idx)
@@ -1679,7 +1679,7 @@ thread_socket (void *arg)
 	    case WAIT_OBJECT_0:
 	      if (!i)	/* Socket event set. */
 		goto out;
-	      /*FALLTHRU*/
+	      fallthrough;
 	    default:
 	      break;
 	    }
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index 7286e3238..a5cf73bde 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -205,7 +205,7 @@ proc_subproc (DWORD what, uintptr_t val)
 	  set_errno (EAGAIN);
 	  break;
 	}
-      /* fall through intentionally */
+      fallthrough;
 
     case PROC_DETACHED_CHILD:
       if (vchild != myself)
@@ -1078,7 +1078,7 @@ child_info::proc_retry (HANDLE h)
     case STATUS_CONTROL_C_EXIT:
       if (saw_ctrl_c ())
 	return EXITCODE_OK;
-      /* fall through intentionally */
+      fallthrough;
     case STATUS_DLL_INIT_FAILED:
     case STATUS_DLL_INIT_FAILED_LOGOFF:
     case EXITCODE_RETRY:
@@ -1387,10 +1387,10 @@ wait_sig (VOID *)
 	    sig_clear (-pack.si.si_signo);
 	  else
 	    sigq.add (pack);
-	  /*FALLTHRU*/
+	  fallthrough;
 	case __SIGNOHOLD:
 	  sig_held = false;
-	  /*FALLTHRU*/
+	  fallthrough;
 	case __SIGFLUSH:
 	case __SIGFLUSHFAST:
 	  if (!sig_held)
diff --git a/winsup/cygwin/smallprint.cc b/winsup/cygwin/smallprint.cc
index 26d34d9e4..9cfb41987 100644
--- a/winsup/cygwin/smallprint.cc
+++ b/winsup/cygwin/smallprint.cc
@@ -180,7 +180,7 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
 		      pad = '0';
 		      continue;
 		    }
-		  /*FALLTHRU*/
+		  fallthrough;
 		case '1' ... '9':
 		  len = len * 10 + (c - '0');
 		  continue;
@@ -254,7 +254,7 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
 		case 'y':
 		  *dst++ = '0';
 		  *dst++ = 'x';
-		  /*FALLTHRU*/
+		  fallthrough;
 		case 'x':
 		  base = 16;
 		  addsign = 0;
@@ -279,7 +279,7 @@ gen_decimal:
 		case 'Y':
 		  *dst++ = '0';
 		  *dst++ = 'x';
-		  /*FALLTHRU*/
+		  fallthrough;
 		case 'X':
 		  base = 16;
 		  addsign = 0;
@@ -299,7 +299,7 @@ gen_decimalLL:
 		  n = strtol (fmt, (char **) &fmt, 10);
 		  if (*fmt++ != 's')
 		    goto endfor;
-		  /*FALLTHRU*/
+		  fallthrough;
 		case 's':
 		  s = va_arg (ap, char *);
 		  if (s == NULL)
@@ -540,7 +540,7 @@ __small_vswprintf (PWCHAR dst, const WCHAR *fmt, va_list ap)
 		      pad = L'0';
 		      continue;
 		    }
-		  /*FALLTHRU*/
+		  fallthrough;
 		case L'1' ... L'9':
 		  len = len * 10 + (c - L'0');
 		  continue;
@@ -597,7 +597,7 @@ __small_vswprintf (PWCHAR dst, const WCHAR *fmt, va_list ap)
 		case 'y':
 		  *dst++ = '0';
 		  *dst++ = 'x';
-		  /*FALLTHRU*/
+		  fallthrough;
 		case 'x':
 		  base = 16;
 		  addsign = 0;
@@ -622,7 +622,7 @@ gen_decimal:
 		case 'Y':
 		  *dst++ = '0';
 		  *dst++ = 'x';
-		  /*FALLTHRU*/
+		  fallthrough;
 		case 'X':
 		  base = 16;
 		  addsign = 0;
@@ -645,7 +645,7 @@ gen_decimalLL:
 		  n = wcstoul (fmt, (wchar_t **) &fmt, 10);
 		  if (*fmt++ != L's')
 		    goto endfor;
-		  /*FALLTHRU*/
+		  fallthrough;
 		case L's':
 		  s = va_arg (ap, char *);
 		  if (s == NULL)
diff --git a/winsup/cygwin/termios.cc b/winsup/cygwin/termios.cc
index 938c2bb7d..b29a64af2 100644
--- a/winsup/cygwin/termios.cc
+++ b/winsup/cygwin/termios.cc
@@ -147,7 +147,7 @@ tcsetattr (int fd, int a, const struct termios *t)
 	  if (_my_tls.call_signal_handler ())
 	    continue;
 	  res = -1;
-	  /* fall through intentionally */
+	  fallthrough;
 	default:
 	  e = get_errno ();
 	  break;
diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc
index e105248c2..c0a0f6163 100644
--- a/winsup/cygwin/uinfo.cc
+++ b/winsup/cygwin/uinfo.cc
@@ -1743,7 +1743,7 @@ pwdgrp::fetch_account_from_file (fetch_user_arg_t &arg)
       /* Override SID with SID string. */
       arg.sid->string (str);
       arg.name = str;
-      /*FALLTHRU*/
+      fallthrough;
     case NAME_arg:
       arg.len = strlen (arg.name);
       break;
@@ -2300,7 +2300,7 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, cyg_ldap *pldap)
 	      if (!its_ok)
 		return NULL;
 	    }
-	  /*FALLTHRU*/
+	  fallthrough;
 	case SidTypeGroup:
 	case SidTypeAlias:
 	  /* Predefined alias? */
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index fff7d18f3..9bfa1a7a6 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -20,6 +20,8 @@ details. */
 #define EXPORT_ALIAS(sym,symalias) __typeof (sym) symalias __attribute__ ((alias(#sym)));
 #endif
 
+#define fallthrough	__attribute__((__fallthrough__))
+
 #define _WIN32_WINNT 0x0a00
 #define WINVER 0x0a00


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-05 20:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-05 20:43 [newlib-cygwin] Cygwin: Add 'fallthrough' pseudo keyword for switch/case use Corinna Vinschen

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).