Skip to content

Commit 1b939ec

Browse files
author
H. Peter Anvin (Intel)
committed
errors: add the ability to hold errors, not just warnings
Re-introduce ERR_HOLD, which means that an error is treated like a warning except for the last pass, but unlike ERR_PASS2 the error message *will* be issued if another error happens on the same pass, just like warnings. This will be used to improve error messages on instruction mismatch. Signed-off-by: H. Peter Anvin (Intel) <[email protected]>
1 parent 9503778 commit 1b939ec

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

asm/error.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,14 @@ void nasm_debug_(unsigned int level, const char *fmt, ...)
8585
nasm_do_error(ERR_DEBUG, LEVEL(level));
8686
}
8787

88+
/*
89+
* Convenience function for nasm_nonfatal(ERR_HOLD, ...)
90+
*/
91+
void nasm_holderr(const char *fmt, ...)
92+
{
93+
nasm_do_error(ERR_NONFATAL, ERR_NONFATAL|ERR_HOLD);
94+
}
95+
8896
fatal_func nasm_panic_from_macro(const char *func, const char *file, int line)
8997
{
9098
if (!func)

asm/nasm.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,13 +1870,12 @@ static errflags pure_func true_error_type(errflags severity)
18701870

18711871
type = severity & ERR_MASK;
18721872

1873-
/* Promote warning to error? */
18741873
if (type == ERR_WARNING) {
1874+
/* Promote warning to error? */
18751875
uint8_t state = warning_state[WARN_IDX(severity)];
18761876
if ((state & warn_is_err) == warn_is_err)
18771877
type = ERR_NONFATAL;
18781878
}
1879-
18801879
return type;
18811880
}
18821881

@@ -2125,6 +2124,7 @@ static void nasm_issue_error(struct nasm_errtext *et)
21252124
const errflags severity = et->severity;
21262125
const errflags true_type = et->true_type;
21272126
const struct src_location where = et->where;
2127+
bool buffer = true_type < ERR_NONFATAL || (severity & ERR_HOLD);
21282128

21292129
if (severity & ERR_NO_SEVERITY)
21302130
pfx = "";
@@ -2167,10 +2167,13 @@ static void nasm_issue_error(struct nasm_errtext *et)
21672167
here = where.filename ? " here" : " in an unknown location";
21682168
}
21692169

2170-
if (warn_list && true_type < ERR_NONFATAL) {
2170+
if (!warn_list)
2171+
buffer = false;
2172+
2173+
if (buffer) {
21712174
/*
2172-
* Buffer up warnings until we either get an error
2173-
* or we are on the code-generation pass.
2175+
* Buffer up warnings and held errors until we either get
2176+
* an error or we are on the code-generation pass.
21742177
*/
21752178
strlist_printf(warn_list, "%s%s%s%s%s%s%s",
21762179
file, linestr, errfmt->beforemsg,
@@ -2180,7 +2183,7 @@ static void nasm_issue_error(struct nasm_errtext *et)
21802183
* Actually output an error. If we have buffered
21812184
* warnings, and this is a non-warning, output them now.
21822185
*/
2183-
if (true_type >= ERR_NONFATAL && warn_list) {
2186+
if (warn_list) {
21842187
strlist_write(warn_list, "\n", error_file);
21852188
strlist_free(&warn_list);
21862189
}
@@ -2216,9 +2219,9 @@ static void nasm_issue_error(struct nasm_errtext *et)
22162219
if (skip_this_pass(severity))
22172220
goto done;
22182221

2219-
if (true_type >= ERR_FATAL)
2222+
if (true_type >= ERR_FATAL) {
22202223
die_hard(true_type, severity);
2221-
else if (true_type >= ERR_NONFATAL) {
2224+
} else if (true_type >= ERR_NONFATAL && !buffer) {
22222225
terminate_after_phase = true;
22232226
errflags_never |= ERR_UNDEAD;
22242227
}

asm/preproc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6464,7 +6464,7 @@ static SMacro *expand_one_smacro(Token ***tpp)
64646464
*/
64656465
while (1) {
64666466
if (!m) {
6467-
nasm_warn(WARN_PP_MACRO_PARAMS_SINGLE|ERR_HOLD,
6467+
nasm_warn(WARN_PP_MACRO_PARAMS_SINGLE,
64686468
"single-line macro `%s' exists, "
64696469
"but not taking %d parameter%s",
64706470
mname, nparam, (nparam == 1) ? "" : "s");

include/error.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ void printf_func(2, 3) nasm_notef(errflags flags, const char *fmt, ...);
2828
void printf_func(2, 3) nasm_warn_(errflags flags, const char *fmt, ...);
2929
void printf_func(1, 2) nasm_nonfatal(const char *fmt, ...);
3030
void printf_func(2, 3) nasm_nonfatalf(errflags flags, const char *fmt, ...);
31+
void printf_func(1, 2) nasm_holderr(const char *fmt, ...);
3132
fatal_func printf_func(1, 2) nasm_fatal(const char *fmt, ...);
3233
fatal_func printf_func(2, 3) nasm_fatalf(errflags flags, const char *fmt, ...);
3334
fatal_func printf_func(1, 2) nasm_critical(const char *fmt, ...);

0 commit comments

Comments
 (0)