compilersupport_p.h: add a macro for the fallthrough attribute

The /* fallthrough */ comment isn't always handled, causing some
compilers to complain about falling through.

Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Thiago Macieira
2025-02-10 14:37:44 -08:00
parent b2dbc005c3
commit 92a02529d2
2 changed files with 15 additions and 1 deletions
+1 -1
View File
@@ -231,7 +231,7 @@ static CborError preparse_value(CborValue *it)
case SinglePrecisionFloat:
case DoublePrecisionFloat:
it->flags |= CborIteratorFlag_IntegerValueTooLarge;
/* fall through */
CBOR_FALLTHROUGH;
case TrueValue:
case NullValue:
case UndefinedValue:
+14
View File
@@ -51,6 +51,20 @@
#else
# define cbor_static_assert(x) ((void)sizeof(char[2*!!(x) - 1]))
#endif
#if defined(__has_cpp_attribute) // C23 and C++17
# if __has_cpp_attribute(fallthrough)
# define CBOR_FALLTHROUGH [[fallthrough]]
# endif
#endif
#ifndef CBOR_FALLTHROUGH
# ifdef __GNUC__
# define CBOR_FALLTHROUGH __attribute__((fallthrough))
# else
# define CBOR_FALLTHROUGH do { } while (0)
# endif
#endif
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__cplusplus)
/* inline is a keyword */
#else