1 Commits
main ... 18

Author SHA1 Message Date
a902c95155 Annotate intentional handler fallthrough
Some checks failed
libakerror CI Build / coverage (push) Successful in 2m51s
libakerror CI Build / cmake_build (push) Successful in 2m53s
libakerror CI Build / thread_sanitizer (push) Failing after 5m53s
libakerror CI Build / mutation_test (push) Successful in 37m49s
Co-authored-by: Andrew Kesterson <andrew@aklabs.net>
2026-08-02 23:52:04 -04:00
2 changed files with 21 additions and 0 deletions

View File

@@ -263,6 +263,14 @@ foreach(_test IN LISTS AKERR_TESTS)
endif() endif()
endforeach() 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( set_tests_properties(
${AKERR_WILL_FAIL_TESTS} ${AKERR_WILL_FAIL_TESTS}
PROPERTIES WILL_FAIL TRUE PROPERTIES WILL_FAIL TRUE

View File

@@ -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 * 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 \ #define ATTEMPT \
switch ( 0 ) { \ switch ( 0 ) { \
case 0: \ case 0: \
@@ -443,6 +455,7 @@ akerr_ErrorContext AKERR_NOIGNORE *__akerr_copy_string(char *destination, int ca
__err_context->handled = true; __err_context->handled = true;
#define HANDLE_GROUP(__err_context, __err_status) \ #define HANDLE_GROUP(__err_context, __err_status) \
AKERR_FALLTHROUGH \
case __err_status: \ case __err_status: \
__err_context->stacktracebufptr = (char *)&__err_context->stacktracebuf; \ __err_context->stacktracebufptr = (char *)&__err_context->stacktracebuf; \
__err_context->handled = true; __err_context->handled = true;