diff mbox series

libbacktrace patch committed: Use __has_attribute for fallthrough

Message ID CAOyqgcXa0OUyQUO1iHMaGynkCTLaO3v6NWJsnU0UB5j3-X+Onw@mail.gmail.com
State New
Headers show
Series libbacktrace patch committed: Use __has_attribute for fallthrough | expand

Commit Message

Ian Lance Taylor July 18, 2024, 6:37 p.m. UTC
This libbacktrace patch uses __has_attribute for fallthrough.  It also
fixes some FALLTHROUGH comments to use ATTRIBUTE_FALLTHROUGH.
Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu.  Committed
to mainline.

Ian

* internal.h: Use __has_attribute to check for fallthrough
attribute.
* elf.c (elf_zstd_decompress): Use ATTRIBUTE_FALLTHROUGH rather
than a FALLTHROUGH comment.
58b219d3cf69a0464d3c74d43e4cc24117e64647
diff mbox series

Patch

diff --git a/libbacktrace/elf.c b/libbacktrace/elf.c
index e8d67feab6d..0040479143d 100644
--- a/libbacktrace/elf.c
+++ b/libbacktrace/elf.c
@@ -4848,25 +4848,25 @@  elf_zstd_decompress (const unsigned char *pin, size_t sin,
 		  {
 		  case 8:
 		    *pout++ = *plit++;
-		    /* FALLTHROUGH */
+		    ATTRIBUTE_FALLTHROUGH;
 		  case 7:
 		    *pout++ = *plit++;
-		    /* FALLTHROUGH */
+		    ATTRIBUTE_FALLTHROUGH;
 		  case 6:
 		    *pout++ = *plit++;
-		    /* FALLTHROUGH */
+		    ATTRIBUTE_FALLTHROUGH;
 		  case 5:
 		    *pout++ = *plit++;
-		    /* FALLTHROUGH */
+		    ATTRIBUTE_FALLTHROUGH;
 		  case 4:
 		    *pout++ = *plit++;
-		    /* FALLTHROUGH */
+		    ATTRIBUTE_FALLTHROUGH;
 		  case 3:
 		    *pout++ = *plit++;
-		    /* FALLTHROUGH */
+		    ATTRIBUTE_FALLTHROUGH;
 		  case 2:
 		    *pout++ = *plit++;
-		    /* FALLTHROUGH */
+		    ATTRIBUTE_FALLTHROUGH;
 		  case 1:
 		    *pout++ = *plit++;
 		    break;
diff --git a/libbacktrace/internal.h b/libbacktrace/internal.h
index a119cda692f..fe2abe50b0f 100644
--- a/libbacktrace/internal.h
+++ b/libbacktrace/internal.h
@@ -56,6 +56,11 @@  POSSIBILITY OF SUCH DAMAGE.  */
 # endif
 #endif
 
+#ifdef __has_attribute
+# if __has_attribute(fallthrough)
+#  define ATTRIBUTE_FALLTHROUGH __attribute__ ((fallthrough))
+# endif
+#endif
 #ifndef ATTRIBUTE_FALLTHROUGH
 # if (GCC_VERSION >= 7000)
 #  define ATTRIBUTE_FALLTHROUGH __attribute__ ((__fallthrough__))