Commit b6a26817 authored by Jinoh Kang's avatar Jinoh Kang Committed by Alexandre Julliard

include/msvcrt: Add noreturn attribute to _assert.

This informs the compiler that no code following an assertion failure will execute (unless NDEBUG is defined), which increases the accuracy of compiler warnings and static analyses. For assert.h, put DECLSPEC_NORETURN before the return type in the function declaration to remain consistent with other MSVCRT function declarations.
parent 36575a2e
...@@ -290,7 +290,7 @@ unsigned int CDECL _set_abort_behavior(unsigned int flags, unsigned int mask) ...@@ -290,7 +290,7 @@ unsigned int CDECL _set_abort_behavior(unsigned int flags, unsigned int mask)
/********************************************************************* /*********************************************************************
* _wassert (MSVCRT.@) * _wassert (MSVCRT.@)
*/ */
void CDECL _wassert(const wchar_t* str, const wchar_t* file, unsigned int line) void DECLSPEC_NORETURN CDECL _wassert(const wchar_t* str, const wchar_t* file, unsigned int line)
{ {
TRACE("(%s,%s,%d)\n", debugstr_w(str), debugstr_w(file), line); TRACE("(%s,%s,%d)\n", debugstr_w(str), debugstr_w(file), line);
...@@ -311,7 +311,7 @@ void CDECL _wassert(const wchar_t* str, const wchar_t* file, unsigned int line) ...@@ -311,7 +311,7 @@ void CDECL _wassert(const wchar_t* str, const wchar_t* file, unsigned int line)
/********************************************************************* /*********************************************************************
* _assert (MSVCRT.@) * _assert (MSVCRT.@)
*/ */
void CDECL _assert(const char* str, const char* file, unsigned int line) void DECLSPEC_NORETURN CDECL _assert(const char* str, const char* file, unsigned int line)
{ {
wchar_t strW[1024], fileW[1024]; wchar_t strW[1024], fileW[1024];
......
...@@ -623,7 +623,7 @@ PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry( ULONG_PTR pc, ULONG_PTR *base, ...@@ -623,7 +623,7 @@ PRUNTIME_FUNCTION WINAPI RtlLookupFunctionEntry( ULONG_PTR pc, ULONG_PTR *base,
/************************************************************* /*************************************************************
* _assert * _assert
*/ */
void __cdecl _assert( const char *str, const char *file, unsigned int line ) void DECLSPEC_NORETURN __cdecl _assert( const char *str, const char *file, unsigned int line )
{ {
ERR( "%s:%u: Assertion failed %s\n", file, line, debugstr_a(str) ); ERR( "%s:%u: Assertion failed %s\n", file, line, debugstr_a(str) );
RtlRaiseStatus( EXCEPTION_WINE_ASSERTION ); RtlRaiseStatus( EXCEPTION_WINE_ASSERTION );
......
...@@ -28,7 +28,7 @@ extern "C" { ...@@ -28,7 +28,7 @@ extern "C" {
#ifdef NDEBUG #ifdef NDEBUG
#define assert(_expr) ((void)0) #define assert(_expr) ((void)0)
#else #else
_ACRTIMP void __cdecl _assert(const char *, const char *, unsigned int); _ACRTIMP DECLSPEC_NORETURN void __cdecl _assert(const char *, const char *, unsigned int);
#define assert(_expr) (void)((!!(_expr)) || (_assert(#_expr, __FILE__, __LINE__), 0)) #define assert(_expr) (void)((!!(_expr)) || (_assert(#_expr, __FILE__, __LINE__), 0))
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment