From 0364c8a773e80a2a492d139fbd06e3d7cf2af098 Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Tue, 5 Sep 2023 16:20:19 +0100 Subject: [PATCH] Introduce MBEDTLS_IGNORE_UNREACHABLE_BEGIN Signed-off-by: Dave Rodgman --- library/common.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/library/common.h b/library/common.h index 3c472c685..4e1b2fa2d 100644 --- a/library/common.h +++ b/library/common.h @@ -334,4 +334,23 @@ static inline void mbedtls_xor_no_simd(unsigned char *r, #define MBEDTLS_OPTIMIZE_FOR_PERFORMANCE #endif +/* Define macros that can be used to disable warnings about unreachable code. */ +#if defined(__clang__) + +#define MBEDTLS_PRAGMA(x) _Pragma(#x) + +#define MBEDTLS_IGNORE_UNREACHABLE_BEGIN \ + MBEDTLS_PRAGMA(clang diagnostic push) \ + MBEDTLS_PRAGMA(clang diagnostic ignored "-Wunreachable-code") + +#define MBEDTLS_IGNORE_UNREACHABLE_END \ + MBEDTLS_PRAGMA(clang diagnostic pop) + +#else + +#define MBEDTLS_IGNORE_UNREACHABLE_BEGIN +#define MBEDTLS_IGNORE_UNREACHABLE_END + +#endif + #endif /* MBEDTLS_LIBRARY_COMMON_H */