libbacktrace patch committed: Use __attribute__((__fallthrough__))
Ian Lance Taylor
iant@golang.org
Tue Oct 20 18:50:14 GMT 2020
This libbacktrace patch uses __attribute__((__fallthrough__)) rather
than relying on a /*fallthrough*/ comment. Bootstrapped and ran
libbacktrace tests on x86_64-pc-linux-gnu. Committed to mainline.
Ian
* internal.h (ATTRIBUTE_FALLTHROUGH): Define.
* elf.c (elf_zlib_inflate): Use ATTRIBUTE_FALLTHROUGH.
-------------- next part --------------
diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index 941f820d944..d52b86cdeb5 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -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;
}
diff --git a/libbacktrace/internal.h b/libbacktrace/internal.h
index 047a700c0ce..659db9e21e2 100644
--- a/libbacktrace/internal.h
+++ b/libbacktrace/internal.h
@@ -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
More information about the Gcc-patches
mailing list