Implement -Wswitch-fallthrough: libgcc

Marek Polacek polacek@redhat.com
Mon Jul 11 19:56:00 GMT 2016


2016-07-11  Marek Polacek  <polacek@redhat.com>

	PR c/7652
	* soft-fp/soft-fp.h (_FP_FALLTHRU): Define.
	* soft-fp/op-common.h: Use it.

diff --git gcc/libgcc/soft-fp/op-common.h gcc/libgcc/soft-fp/op-common.h
index 080ef0e..6691f50 100644
--- gcc/libgcc/soft-fp/op-common.h
+++ gcc/libgcc/soft-fp/op-common.h
@@ -898,6 +898,7 @@
 	case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_INF):		\
 	case _FP_CLS_COMBINE (FP_CLS_NAN, FP_CLS_ZERO):		\
 	  R##_s = X##_s;					\
+	  _FP_FALLTHRU ();						\
 								\
 	case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_INF):		\
 	case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_NORMAL):	\
@@ -911,6 +912,7 @@
 	case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_NAN):		\
 	case _FP_CLS_COMBINE (FP_CLS_ZERO, FP_CLS_NAN):		\
 	  R##_s = Y##_s;					\
+	  _FP_FALLTHRU ();						\
 								\
 	case _FP_CLS_COMBINE (FP_CLS_NORMAL, FP_CLS_INF):	\
 	case _FP_CLS_COMBINE (FP_CLS_NORMAL, FP_CLS_ZERO):	\
@@ -1198,6 +1200,7 @@
 								\
 	case _FP_CLS_COMBINE (FP_CLS_NORMAL, FP_CLS_ZERO):	\
 	  FP_SET_EXCEPTION (FP_EX_DIVZERO);			\
+	  _FP_FALLTHRU ();						\
 	case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_ZERO):		\
 	case _FP_CLS_COMBINE (FP_CLS_INF, FP_CLS_NORMAL):	\
 	  R##_c = FP_CLS_INF;					\
diff --git gcc/libgcc/soft-fp/soft-fp.h gcc/libgcc/soft-fp/soft-fp.h
index 3b39336..999b145 100644
--- gcc/libgcc/soft-fp/soft-fp.h
+++ gcc/libgcc/soft-fp/soft-fp.h
@@ -71,6 +71,12 @@
     [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
 #endif
 
+#if (defined __GNUC__ && __GNUC__ >= 7)
+# define _FP_FALLTHRU() __builtin_fallthrough ()
+#else
+# define _FP_FALLTHRU()
+#endif
+
 /* In the Linux kernel, some architectures have a single function that
    uses different kinds of unpacking and packing depending on the
    instruction being emulated, meaning it is not readily visible to



More information about the Gcc-patches mailing list