From f944b08878ba07ffb71bdd6e3dde273d82b4bf16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bernhard=20Breu=C3=9F?= Date: Wed, 2 Jun 2021 16:56:14 +0200 Subject: [PATCH] Use stdnoreturn.h for c11 and [[ noreturn ]] for c++11. ThrowTheSwitch#563 --- src/unity_internals.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/unity_internals.h b/src/unity_internals.h index 75c2df6f..4e5629bb 100644 --- a/src/unity_internals.h +++ b/src/unity_internals.h @@ -46,6 +46,20 @@ #define UNITY_FUNCTION_ATTR(a) /* ignore */ #endif +#ifndef UNITY_NORETURN + #if defined(__cplusplus) + #if __cplusplus >= 201103L + #define UNITY_NORETURN [[ noreturn ]] + #endif + #elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L + #include + #define UNITY_NORETURN noreturn + #endif +#endif +#ifndef UNITY_NORETURN + #define UNITY_NORETURN UNITY_FUNCTION_ATTR(noreturn) +#endif + /*------------------------------------------------------- * Guess Widths If Not Specified *-------------------------------------------------------*/ @@ -618,8 +632,8 @@ void UnityAssertNumbersArrayWithin(const UNITY_UINT delta, const UNITY_FLAGS_T flags); #ifndef UNITY_EXCLUDE_SETJMP_H -void UnityFail(const char* message, const UNITY_LINE_TYPE line) UNITY_FUNCTION_ATTR(noreturn); -void UnityIgnore(const char* message, const UNITY_LINE_TYPE line) UNITY_FUNCTION_ATTR(noreturn); +UNITY_NORETURN void UnityFail(const char* message, const UNITY_LINE_TYPE line); +UNITY_NORETURN void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); #else void UnityFail(const char* message, const UNITY_LINE_TYPE line); void UnityIgnore(const char* message, const UNITY_LINE_TYPE line);