Promote switch-exhaustiveness diagnostic to an error on pure libraries (MSVC + GCC/Clang)
MSVC's C4062 is off by default and GCC/Clang's -Wswitch only warns without -Werror; this repo sets no -Wall/-Werror anywhere. /we4062 and -Werror=switch now cover both, scoped to pure libraries only.
This commit is contained in:
@@ -12,6 +12,17 @@ function(reasampler_pure_library name)
|
|||||||
if(ARG_LINK)
|
if(ARG_LINK)
|
||||||
target_link_libraries(${name} ${ARG_LINK})
|
target_link_libraries(${name} ${ARG_LINK})
|
||||||
endif()
|
endif()
|
||||||
|
# A default-less switch missing an enumerator: MSVC's C4062 is off by its /W1 default;
|
||||||
|
# GCC/Clang's -Wswitch is on by default but only warns without -Werror, and this repo
|
||||||
|
# sets no -Wall/-Werror/-W4/-WX anywhere. Promoted to an error only here, on our own
|
||||||
|
# pure libraries, so a deliberately default-less switch (e.g. isLiveDeckParam,
|
||||||
|
# deck_groups.cpp) is a compile error on every toolchain. NOT C4061 (fires even with
|
||||||
|
# a default: present) — that would light up every defensive switch in the tree.
|
||||||
|
if(MSVC)
|
||||||
|
target_compile_options(${name} PRIVATE /we4062)
|
||||||
|
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||||
|
target_compile_options(${name} PRIVATE -Werror=switch)
|
||||||
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Test naming is exceptionless: target <name>_tests is built from tests/test_<name>.cpp
|
# Test naming is exceptionless: target <name>_tests is built from tests/test_<name>.cpp
|
||||||
|
|||||||
@@ -199,9 +199,10 @@ bool isLiveDeckParam(DeckParam id) {
|
|||||||
case DeckParam::kFilterTrigAttackCurve:
|
case DeckParam::kFilterTrigAttackCurve:
|
||||||
case DeckParam::kFilterTrigDecayCurve:
|
case DeckParam::kFilterTrigDecayCurve:
|
||||||
return true;
|
return true;
|
||||||
// Listed rather than defaulted so a newly added control is a COMPILE error here (the
|
// Listed rather than defaulted so a newly added control is a COMPILE error here on
|
||||||
// -Wswitch gate is GCC/Clang; MSVC's C4062 is off at this project's warning level)
|
// every toolchain — /we4062 on MSVC, -Werror=switch on GCC/Clang, both set on this
|
||||||
// instead of silently defaulting to non-live. Reasons live in the header.
|
// library alone in cmake/reasampler_targets.cmake — instead of silently defaulting
|
||||||
|
// to non-live. Reasons live in the header.
|
||||||
case DeckParam::kPlayMode:
|
case DeckParam::kPlayMode:
|
||||||
case DeckParam::kPitchEngine:
|
case DeckParam::kPitchEngine:
|
||||||
case DeckParam::kTrigLength:
|
case DeckParam::kTrigLength:
|
||||||
|
|||||||
Reference in New Issue
Block a user