mirror of
https://github.com/netwide-assembler/nasm.git
synced 2024-12-15 09:09:58 +08:00
nasm.c: correctly print errors once committed; assert errhold_stack empty
Properly format the error messages when we print them (oops!) The errhold_stack should be empty after each pass. It may even be worthwhile to make sure it is empty after each *line*, but do this for now. Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
parent
c44709c964
commit
283bc92a92
15
asm/nasm.c
15
asm/nasm.c
@ -1,4 +1,4 @@
|
||||
/* ----------------------------------------------------------------------- *
|
||||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 1996-2020 The NASM Authors - All Rights Reserved
|
||||
* See the file AUTHORS included with the NASM distribution for
|
||||
@ -87,6 +87,7 @@ static const struct error_format errfmt_gnu = { ":", "", ": " };
|
||||
static const struct error_format errfmt_msvc = { "(", ")", " : " };
|
||||
static const struct error_format *errfmt = &errfmt_gnu;
|
||||
static struct strlist *warn_list;
|
||||
static struct nasm_errhold *errhold_stack;
|
||||
|
||||
unsigned int debug_nasm; /* Debugging messages? */
|
||||
|
||||
@ -1663,6 +1664,9 @@ static void assemble_file(const char *fname, struct strlist *depend_list)
|
||||
|
||||
preproc->cleanup_pass();
|
||||
|
||||
/* We better not be having an error hold still... */
|
||||
nasm_assert(!errhold_stack);
|
||||
|
||||
if (global_offset_changed) {
|
||||
switch (pass_type()) {
|
||||
case PASS_OPT:
|
||||
@ -1907,7 +1911,6 @@ struct nasm_errhold {
|
||||
struct nasm_errhold *up;
|
||||
struct nasm_errtext *head, **tail;
|
||||
};
|
||||
static struct nasm_errhold *errhold_stack;
|
||||
|
||||
static void nasm_free_error(struct nasm_errtext *et)
|
||||
{
|
||||
@ -2069,15 +2072,17 @@ static void nasm_issue_error(struct nasm_errtext *et)
|
||||
pfx, et->msg, here, warnsuf);
|
||||
} else {
|
||||
/*
|
||||
* If we have buffered warnings, and this is a non-warning,
|
||||
* output them now.
|
||||
* Actually output an error. If we have buffered
|
||||
* warnings, and this is a non-warning, output them now.
|
||||
*/
|
||||
if (true_type >= ERR_NONFATAL && warn_list) {
|
||||
strlist_write(warn_list, "\n", error_file);
|
||||
strlist_free(&warn_list);
|
||||
}
|
||||
|
||||
fprintf(error_file, "%s\n", et->msg);
|
||||
fprintf(error_file, "%s%s%s%s%s%s%s\n",
|
||||
file, linestr, errfmt->beforemsg,
|
||||
pfx, et->msg, here, warnsuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user