Use stdnoreturn instead of our own APFL_NORETURN
This commit is contained in:
parent
b026494891
commit
f4841ff2cd
5 changed files with 18 additions and 23 deletions
17
src/apfl.h
17
src/apfl.h
|
|
@ -8,12 +8,7 @@ extern "C" {
|
|||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define APFL_NORETURN __attribute__((noreturn))
|
||||
#else
|
||||
# define APFL_NORETURN
|
||||
#endif
|
||||
#include <stdnoreturn.h>
|
||||
|
||||
// Allocator
|
||||
|
||||
|
|
@ -767,15 +762,15 @@ bool apfl_call_stack_entry_info_format(struct apfl_io_writer, struct apfl_call_s
|
|||
bool apfl_debug_print_val(apfl_ctx, apfl_stackidx, struct apfl_io_writer);
|
||||
|
||||
// Raise an error with a value from the stack as the message.
|
||||
APFL_NORETURN void apfl_raise_error(apfl_ctx, apfl_stackidx);
|
||||
noreturn void apfl_raise_error(apfl_ctx, apfl_stackidx);
|
||||
// Raise an error with a constant string as the message.
|
||||
APFL_NORETURN void apfl_raise_const_error(apfl_ctx, const char *message);
|
||||
noreturn void apfl_raise_const_error(apfl_ctx, const char *message);
|
||||
// Raise a memory allocation error.
|
||||
APFL_NORETURN void apfl_raise_alloc_error(apfl_ctx);
|
||||
noreturn void apfl_raise_alloc_error(apfl_ctx);
|
||||
// Raise an error for invalid stack indices.
|
||||
APFL_NORETURN void apfl_raise_invalid_stackidx(apfl_ctx);
|
||||
noreturn void apfl_raise_invalid_stackidx(apfl_ctx);
|
||||
// Raise an error with a message derived from an struct apfl_error.
|
||||
APFL_NORETURN void apfl_raise_error_object(apfl_ctx, struct apfl_error);
|
||||
noreturn void apfl_raise_error_object(apfl_ctx, struct apfl_error);
|
||||
|
||||
struct apfl_messages {
|
||||
const char *invalid_stack_index;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ static bool try_push_const_string(apfl_ctx ctx, const char *string);
|
|||
static bool current_stack_move_to_top(apfl_ctx, apfl_stackidx);
|
||||
static struct apfl_string *new_copied_string(struct gc *, struct apfl_string_view);
|
||||
|
||||
APFL_NORETURN static void
|
||||
noreturn static void
|
||||
panic(apfl_ctx ctx, enum apfl_result result)
|
||||
{
|
||||
(void)ctx;
|
||||
|
|
@ -154,7 +154,7 @@ apfl_call_protected(apfl_ctx ctx, apfl_stackidx func, apfl_stackidx args)
|
|||
return apfl_do_protected(ctx, call_protected_cb, &data, NULL);
|
||||
}
|
||||
|
||||
APFL_NORETURN static void
|
||||
noreturn static void
|
||||
raise_error(apfl_ctx ctx, enum apfl_result type)
|
||||
{
|
||||
assert(type != APFL_RESULT_OK);
|
||||
|
|
@ -170,7 +170,7 @@ raise_error(apfl_ctx ctx, enum apfl_result type)
|
|||
panic(ctx, type);
|
||||
}
|
||||
|
||||
APFL_NORETURN void
|
||||
noreturn void
|
||||
apfl_raise_error(apfl_ctx ctx, apfl_stackidx idx)
|
||||
{
|
||||
if (!current_stack_move_to_top(ctx, idx)) {
|
||||
|
|
@ -179,7 +179,7 @@ apfl_raise_error(apfl_ctx ctx, apfl_stackidx idx)
|
|||
raise_error(ctx, APFL_RESULT_ERR);
|
||||
}
|
||||
|
||||
APFL_NORETURN void
|
||||
noreturn void
|
||||
apfl_raise_const_error(apfl_ctx ctx, const char *message)
|
||||
{
|
||||
if (!try_push_const_string(ctx, message)) {
|
||||
|
|
@ -188,19 +188,19 @@ apfl_raise_const_error(apfl_ctx ctx, const char *message)
|
|||
raise_error(ctx, APFL_RESULT_ERR);
|
||||
}
|
||||
|
||||
APFL_NORETURN void
|
||||
noreturn void
|
||||
apfl_raise_alloc_error(apfl_ctx ctx)
|
||||
{
|
||||
raise_error(ctx, APFL_RESULT_ERR_ALLOC);
|
||||
}
|
||||
|
||||
APFL_NORETURN void
|
||||
noreturn void
|
||||
apfl_raise_invalid_stackidx(apfl_ctx ctx)
|
||||
{
|
||||
apfl_raise_const_error(ctx, apfl_messages.invalid_stack_index);
|
||||
}
|
||||
|
||||
APFL_NORETURN void
|
||||
noreturn void
|
||||
apfl_raise_error_object(apfl_ctx ctx, struct apfl_error error)
|
||||
{
|
||||
if (error.type == APFL_ERR_MALLOC_FAILED) {
|
||||
|
|
@ -275,7 +275,7 @@ static const struct format_spec errorfmt_specs[] = {
|
|||
{NULL, NULL},
|
||||
};
|
||||
|
||||
APFL_NORETURN void
|
||||
noreturn void
|
||||
apfl_raise_errorfmt(apfl_ctx ctx, const char *fmt, ...)
|
||||
{
|
||||
struct errorfmt_data data = {
|
||||
|
|
@ -1697,7 +1697,7 @@ apfl_push_cfunc(apfl_ctx ctx, apfl_cfunc cfunc, size_t nslots)
|
|||
)
|
||||
}
|
||||
|
||||
static APFL_NORETURN void
|
||||
static noreturn void
|
||||
raise_no_cfunc(apfl_ctx ctx)
|
||||
{
|
||||
apfl_raise_const_error(ctx, apfl_messages.not_a_c_function);
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ struct apfl_string *apfl_to_dynamic_string(apfl_ctx ctx, apfl_stackidx index);
|
|||
* `apfl_stackidx` is expected instead and the type of the value at the given
|
||||
* stack index is used instead.
|
||||
*/
|
||||
APFL_NORETURN void apfl_raise_errorfmt(apfl_ctx ctx, const char *fmt, ...);
|
||||
noreturn void apfl_raise_errorfmt(apfl_ctx ctx, const char *fmt, ...);
|
||||
|
||||
struct call_stack_entry *apfl_call_stack_cur_entry(apfl_ctx);
|
||||
|
||||
|
|
|
|||
|
|
@ -713,7 +713,7 @@ matcher_state_push(apfl_ctx ctx, struct matcher_call_stack_entry *cse, struct ma
|
|||
}
|
||||
}
|
||||
|
||||
APFL_NORETURN static void
|
||||
noreturn static void
|
||||
raise_invalid_matcher_state(apfl_ctx ctx)
|
||||
{
|
||||
apfl_raise_const_error(ctx, apfl_messages.invalid_matcher_state);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ struct test_parts {
|
|||
struct apfl_string_view output;
|
||||
};
|
||||
|
||||
APFL_NORETURN static void
|
||||
noreturn static void
|
||||
fatal(jmp_buf *jmp, const char *fmt, ...)
|
||||
{
|
||||
va_list varargs;
|
||||
|
|
|
|||
Loading…
Reference in a new issue