Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use stdnoreturn.h for c11 and [[ noreturn ]] for c++11. Fixes #563 #564

Merged
merged 1 commit into from
Jun 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/unity_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <stdnoreturn.h>
#define UNITY_NORETURN noreturn
#endif
#endif
#ifndef UNITY_NORETURN
#define UNITY_NORETURN UNITY_FUNCTION_ATTR(noreturn)
#endif

/*-------------------------------------------------------
* Guess Widths If Not Specified
*-------------------------------------------------------*/
Expand Down Expand Up @@ -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);
Expand Down