From 8766b939f175c16dc3c4bcda03593e0a0fed61f2 Mon Sep 17 00:00:00 2001 From: David Detlefs Date: Sat, 8 Aug 2026 09:44:08 -0700 Subject: [PATCH] Add a default back in for a case where gcc (erroneously) claims control flow reaches end without return. Must also locally disable the clang covered-switch-default warning. --- src/util/ext_numeral.h | 11 +++++++++++ src/util/manage_warnings.h | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/src/util/ext_numeral.h b/src/util/ext_numeral.h index 169f72f344..925d05baa3 100644 --- a/src/util/ext_numeral.h +++ b/src/util/ext_numeral.h @@ -21,6 +21,7 @@ Revision History: #include #include "util/debug.h" +#include "util/manage_warnings.h" enum ext_numeral_kind { EN_MINUS_INFINITY, EN_NUMERAL, EN_PLUS_INFINITY }; @@ -280,6 +281,16 @@ bool lt(numeral_manager & m, return m.lt(a, b); case EN_PLUS_INFINITY: return true; + + // The default case below is not necessary: the cases above cover all the + // elements of the ext_numeral_kind enum. But gcc complains with a warning + // if this default case is absent. So we leave it in, but disable Clang's + // (correct) warning that the default is unnecessary. + START_DISABLE_COVERED_SWITCH_DEFAULT; + default: + UNREACHABLE(); + return false; + END_DISABLE_WARNING_STMT; } case EN_PLUS_INFINITY: return false; diff --git a/src/util/manage_warnings.h b/src/util/manage_warnings.h index 8be99dc4cb..6bebb3af78 100644 --- a/src/util/manage_warnings.h +++ b/src/util/manage_warnings.h @@ -42,15 +42,22 @@ Revision History: DO_PRAGMA(clang diagnostic ignored #s) +// This version should be used in decl contexts. #define END_DISABLE_WARNING \ _Pragma("clang diagnostic pop") \ DUMMY_DECL +// This version should be used in statement contexts. +#define END_DISABLE_WARNING_STMT \ + _Pragma("clang diagnostic pop") + #define START_DISABLE_EXTRA_SEMI_WARNING START_DISABLE_WARNING(-Wextra-semi) +#define START_DISABLE_COVERED_SWITCH_DEFAULT START_DISABLE_WARNING(-Wcovered-switch-default) #else #define START_DISABLE_EXTRA_SEMI_WARNING +#define START_DISABLE_COVERED_SWITCH_DEFAULT #define END_DISABLE_WARNING #endif