From ea1a4b79327ac70ea6ac4849ad889e3b9e0ce157 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sat, 6 Feb 2021 17:01:17 -0600 Subject: [PATCH] Explicitly annotate intentional switch fallthrough This silences a very useful warning in GCC 10. --- config_cmake.h.in | 6 ++++++ src/reader.cpp | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config_cmake.h.in b/config_cmake.h.in index 5266f6eb0..dceb16092 100644 --- a/config_cmake.h.in +++ b/config_cmake.h.in @@ -198,3 +198,9 @@ #else #define __warn_unused_type #endif + +#if __has_attribute(fallthrough) +#define __fallthrough__ __attribute__ ((fallthrough)) +#else +#define __fallthrough__ +#endif diff --git a/src/reader.cpp b/src/reader.cpp index cd63a15da..50c1788a0 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -2941,9 +2941,9 @@ void reader_data_t::handle_readline_command(readline_cmd_t c, readline_loop_stat parser().libdata().is_repaint = false; break; } - // Else we repaint as normal + // Else we repaint as normal. + __fallthrough__ } - /* fallthrough */ case rl::force_repaint: case rl::repaint: { parser().libdata().is_repaint = true;