Annotate intentional handler fallthrough
Co-authored-by: Andrew Kesterson <andrew@aklabs.net>
This commit is contained in:
@@ -263,6 +263,14 @@ foreach(_test IN LISTS AKERR_TESTS)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# HANDLE_GROUP deliberately enters the next case label. Keep that public macro
|
||||
# compiling with the warning enabled, so a future macro edit cannot restore the
|
||||
# warning for consumers which adopt -Wextra.
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang")
|
||||
target_compile_options(test_err_handle_group PRIVATE
|
||||
-Werror=implicit-fallthrough)
|
||||
endif()
|
||||
|
||||
set_tests_properties(
|
||||
${AKERR_WILL_FAIL_TESTS}
|
||||
PROPERTIES WILL_FAIL TRUE
|
||||
|
||||
@@ -391,6 +391,18 @@ akerr_ErrorContext AKERR_NOIGNORE *__akerr_copy_string(char *destination, int ca
|
||||
* Defines for the ATTEMPT/CATCH/CLEANUP/PROCESS/HANDLE/FINISH process
|
||||
*/
|
||||
|
||||
/*
|
||||
* HANDLE_GROUP deliberately enters the next case label. GCC and clang both
|
||||
* understand this spelling in the C modes supported by libakerror. Other
|
||||
* compilers keep the established control flow without receiving an attribute
|
||||
* they do not implement.
|
||||
*/
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define AKERR_FALLTHROUGH __attribute__((fallthrough));
|
||||
#else
|
||||
#define AKERR_FALLTHROUGH
|
||||
#endif
|
||||
|
||||
#define ATTEMPT \
|
||||
switch ( 0 ) { \
|
||||
case 0: \
|
||||
@@ -443,6 +455,7 @@ akerr_ErrorContext AKERR_NOIGNORE *__akerr_copy_string(char *destination, int ca
|
||||
__err_context->handled = true;
|
||||
|
||||
#define HANDLE_GROUP(__err_context, __err_status) \
|
||||
AKERR_FALLTHROUGH \
|
||||
case __err_status: \
|
||||
__err_context->stacktracebufptr = (char *)&__err_context->stacktracebuf; \
|
||||
__err_context->handled = true;
|
||||
|
||||
Reference in New Issue
Block a user