Replace __noreturn with C++11 [[noreturn]]

This allows non-GNU-C compilers to see the attribute.
This commit is contained in:
Kp 2021-06-28 03:37:50 +00:00
parent a3bf147768
commit 15057af2f9
2 changed files with 13 additions and 17 deletions

View file

@ -31,14 +31,6 @@ COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
#include "dsx-ns.h"
#include <assert.h>
#ifdef __cplusplus
#ifdef __GNUC__
#define __noreturn __attribute__ ((noreturn))
#else
#define __noreturn
#endif
namespace dcx {
void Warning_puts(const char *str) __attribute_nonnull();
@ -48,26 +40,28 @@ void Warning(const char *fmt,...) __attribute_format_printf(1, 2); //print ou
void set_warn_func(void (*f)(const char *s));//specifies the function to call with warning messages
void clear_warn_func();//say this function no longer valid
#endif
__noreturn
__attribute_nonnull()
[[noreturn]]
void Error_puts(const char *file, unsigned line, const char *func, const char *str);
#define Error_puts(F) Error_puts(__FILE__, __LINE__, __func__, F)
__noreturn
__attribute_format_printf(4, 5)
__attribute_nonnull()
[[noreturn]]
void Error(const char *file, unsigned line, const char *func, const char *fmt,...); //exit with error code=1, print message
#define Error(F,...) dxx_call_printf_checked(Error,(Error_puts),(__FILE__, __LINE__, __func__),(F),##__VA_ARGS__)
__noreturn
[[noreturn]]
void UserError_puts(const char *str, std::size_t);
template <std::size_t len>
__noreturn
[[noreturn]]
static inline void UserError_puts(const char (&str)[len])
{
UserError_puts(str, len - 1);
}
void UserError(const char *fmt, ...) __noreturn __attribute_format_printf(1, 2);
[[noreturn]]
void UserError(const char *fmt, ...) __attribute_format_printf(1, 2);
}
#define DXX_STRINGIZE_FL2(F,L,S) F ":" #L ": " S
@ -129,5 +123,3 @@ static inline void d_debugbreak()
}
}
#endif

View file

@ -59,13 +59,15 @@ void clear_warn_func()
constexpr auto warn_func = &warn_printf;
#endif
namespace {
static void print_exit_message(const char *exit_message, size_t len)
{
con_puts(CON_CRITICAL, exit_message, len);
msgbox_error(exit_message);
}
__noreturn
[[noreturn]]
static void abort_print_exit_message(const char *exit_message, size_t len)
{
print_exit_message(exit_message, len);
@ -73,13 +75,15 @@ static void abort_print_exit_message(const char *exit_message, size_t len)
std::abort();
}
__noreturn
[[noreturn]]
static void graceful_print_exit_message(const char *exit_message, size_t len)
{
print_exit_message(exit_message, len);
exit(1);
}
}
void (Error_puts)(const char *filename, const unsigned line, const char *func, const char *str)
{
char exit_message[MAX_MSG_LEN]; // don't put the new line in for dialog output