[build] enforce exhaustive switch statements in BUILD_WERROR config
Summary:
D6079 introduced a function that switches over an enum class parameter
and returns a std::string, which raises a warning from the compiler that
"control reaches end of non-void function". since this should never
happen, an assert(false) after the switch silences that warning.
to really bulletproof it though, defaultless switch statements over an enum
value that do not have a specific case for each should raise an error and not a warning
edit: also promoted -Wreturn-type to an error, h/t @deadalnix
ref: https://abseil.io/tips/147
Test Plan:
add another value to PSBTRole enum class in src/psbt.h without changing the
definition of std::string PSBTRoleName(PSBTRole role);
cmake .. -GNinja -WENABLE_WERROR:BOOL=True ninja
notice that this raises an error:
../src/psbt.cpp:282:13: error: enumeration value 'TESTER' not handled in switch [-Werror,-Wswitch] switch (role) {
without the WENABLE_WERROR flag set, it'll only emit a warning.
Reviewers: #bitcoin_abc, deadalnix
Reviewed By: #bitcoin_abc, deadalnix
Subscribers: deadalnix
Differential Revision: https://reviews.bitcoinabc.org/D6107