diff options
author | H. Peter Anvin (Intel) <hpa@zytor.com> | 2020-07-03 18:44:55 -0700 |
---|---|---|
committer | H. Peter Anvin (Intel) <hpa@zytor.com> | 2020-07-03 19:02:37 -0700 |
commit | 87a832e391ccf5a24dc70ceec1e13d94df16968e (patch) | |
tree | 4e1480d15a5473395cc9419bc0b46feb786985bd | |
parent | 61be48a383dd951f036631ea35723f2a6a8b96ee (diff) | |
download | nasm-87a832e391ccf5a24dc70ceec1e13d94df16968e.tar.gz |
BR 3392691: errors: issue ERR_PASS2 messages in preproc-only mode
In preproc-only mode, we only ever execute a single pass, so we need
to still issue error messages created during that pass, otherwise we
don't even generate %warning or %error messages...
Reported-by: Jason Hood <jadoxa@yahoo.com.au>
Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
-rw-r--r-- | asm/nasm.c | 23 | ||||
-rw-r--r-- | include/nasm.h | 6 |
2 files changed, 25 insertions, 4 deletions
@@ -644,7 +644,7 @@ int main(int argc, char **argv) location.known = false; - _pass_type = PASS_FIRST; /* We emulate this assembly pass */ + _pass_type = PASS_PREPROC; preproc->reset(inname, PP_PREPROC, depend_list); while ((line = preproc->getline())) { @@ -1651,8 +1651,19 @@ static void assemble_file(const char *fname, struct strlist *depend_list) while (!terminate_after_phase && !pass_final()) { _passn++; - if (pass_type() != PASS_OPT || !global_offset_changed) + switch (pass_type()) { + case PASS_INIT: + _pass_type = PASS_FIRST; + break; + case PASS_OPT: + if (global_offset_changed) + break; /* One more optimization pass */ + /* fall through */ + default: _pass_type++; + break; + } + global_offset_changed = 0; /* @@ -1830,8 +1841,12 @@ static bool skip_this_pass(errflags severity) if (type == ERR_LISTMSG) return true; - /* This message not applicable unless pass_final */ - return (severity & ERR_PASS2) && !pass_final(); + /* + * This message not applicable unless it is the last pass we are going + * to execute; this can be either the final code-generation pass or + * the single pass executed in preproc-only mode. + */ + return (severity & ERR_PASS2) && !pass_final_or_preproc(); } /** diff --git a/include/nasm.h b/include/nasm.h index 046f5fb9..91dc9e6f 100644 --- a/include/nasm.h +++ b/include/nasm.h @@ -1284,6 +1284,7 @@ struct optimization { */ enum pass_type { PASS_INIT, /* Initialization, not doing anything yet */ + PASS_PREPROC, /* Preprocess-only mode (similar to PASS_FIRST) */ PASS_FIRST, /* The very first pass over the code */ PASS_OPT, /* Optimization pass */ PASS_STAB, /* Stabilization pass (original pass 1) */ @@ -1319,6 +1320,11 @@ static inline bool pass_final(void) { return pass_type() >= PASS_FINAL; } +/* True for code generation *or* preprocess-only mode */ +static inline bool pass_final_or_preproc(void) +{ + return pass_type() >= PASS_FINAL || pass_type() == PASS_PREPROC; +} /* * The actual pass number. 0 is used during initialization, the very |