libbacktrace: use __attribute__((__fallthrough__))
authorIan Lance Taylor <iant@golang.org>
Tue, 20 Oct 2020 18:47:35 +0000 (11:47 -0700)
committerIan Lance Taylor <iant@golang.org>
Tue, 20 Oct 2020 18:49:58 +0000 (11:49 -0700)
Use an attribute rather than a comment when falling through a switch case.

* internal.h (ATTRIBUTE_FALLTHROUGH): Define.
* elf.c (elf_zlib_inflate): Use ATTRIBUTE_FALLTHROUGH.

libbacktrace/elf.c
libbacktrace/internal.h

index 941f820d944c76ec349a597ce32bf7fa7acb4693..d52b86cdeb5d9a88797fd6cd769843d4d141c1af 100644 (file)
@@ -2081,10 +2081,10 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
                        {
                        case 6:
                          *plen++ = prev;
-                         /* fallthrough */
+                         ATTRIBUTE_FALLTHROUGH;
                        case 5:
                          *plen++ = prev;
-                         /* fallthrough */
+                         ATTRIBUTE_FALLTHROUGH;
                        case 4:
                          *plen++ = prev;
                        }
@@ -2115,22 +2115,22 @@ elf_zlib_inflate (const unsigned char *pin, size_t sin, uint16_t *zdebug_table,
                        {
                        case 10:
                          *plen++ = 0;
-                         /* fallthrough */
+                         ATTRIBUTE_FALLTHROUGH;
                        case 9:
                          *plen++ = 0;
-                         /* fallthrough */
+                         ATTRIBUTE_FALLTHROUGH;
                        case 8:
                          *plen++ = 0;
-                         /* fallthrough */
+                         ATTRIBUTE_FALLTHROUGH;
                        case 7:
                          *plen++ = 0;
-                         /* fallthrough */
+                         ATTRIBUTE_FALLTHROUGH;
                        case 6:
                          *plen++ = 0;
-                         /* fallthrough */
+                         ATTRIBUTE_FALLTHROUGH;
                        case 5:
                          *plen++ = 0;
-                         /* fallthrough */
+                         ATTRIBUTE_FALLTHROUGH;
                        case 4:
                          *plen++ = 0;
                        }
index 047a700c0ce469ad241d321864a80b95e5793769..659db9e21e2bf4bfba15e72078d31179e23c27bd 100644 (file)
@@ -56,6 +56,14 @@ POSSIBILITY OF SUCH DAMAGE.  */
 # endif
 #endif
 
+#ifndef ATTRIBUTE_FALLTHROUGH
+# if (GCC_VERSION >= 7000)
+#  define ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))
+# else
+#  define ATTRIBUTE_FALLTHROUGH
+# endif
+#endif
+
 #ifndef HAVE_SYNC_FUNCTIONS
 
 /* Define out the sync functions.  These should never be called if