From 48ef41957ad199eff524ed8d39b4fe27d844e80c Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Wed, 1 Jul 2009 22:12:59 -0700 Subject: [PATCH] Fix early report_error(); avoid nuisance phase warnings Fix report_error() to (hopefully) not fault if used without ERR_NOFILE if no filename is available. Avoid nuisance phase error between passes warnings if we have detected other errors. In those case, the phase error is almost certainly spurious. Signed-off-by: H. Peter Anvin --- nasm.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/nasm.c b/nasm.c index 3def14eb..47595772 100644 --- a/nasm.c +++ b/nasm.c @@ -1733,7 +1733,7 @@ static void assemble_file(char *fname, StrList **depend_ptr) location.offset = offs = GET_CURR_OFFS; } /* end while (line = preproc->getline... */ - if (pass0 && global_offset_changed) + if (pass0 == 2 && global_offset_changed && !terminate_after_phase) report_error(ERR_NONFATAL, "phase error detected at end of assembly."); @@ -1762,7 +1762,6 @@ static void assemble_file(char *fname, StrList **depend_ptr) "after %d passes, giving up.", passn); report_error(ERR_NONFATAL, "Possible causes: recursive EQUs, macro abuse."); - terminate_after_phase = true; break; } } @@ -1841,19 +1840,22 @@ static enum directives getkw(char **directive, char **value) static void report_error_gnu(int severity, const char *fmt, ...) { va_list ap; + char *currentfile = NULL; + int32_t lineno = 0; if (is_suppressed_warning(severity)) return; - if (severity & ERR_NOFILE) - fputs("nasm: ", error_file); - else { - char *currentfile = NULL; - int32_t lineno = 0; + if (!(severity & ERR_NOFILE)) src_get(&lineno, ¤tfile); - fprintf(error_file, "%s:%"PRId32": ", currentfile, lineno); - nasm_free(currentfile); + + if (currentfile) { + fprintf(error_file, "%s:%"PRId32": ", currentfile, lineno); + nasm_free(currentfile); + } else { + fputs("nasm: ", error_file); } + va_start(ap, fmt); report_error_common(severity, fmt, ap); va_end(ap); @@ -1877,19 +1879,22 @@ static void report_error_gnu(int severity, const char *fmt, ...) static void report_error_vc(int severity, const char *fmt, ...) { va_list ap; + char *currentfile = NULL; + int32_t lineno = 0; if (is_suppressed_warning(severity)) return; - if (severity & ERR_NOFILE) - fputs("nasm: ", error_file); - else { - char *currentfile = NULL; - int32_t lineno = 0; + if (!(severity & ERR_NOFILE)) src_get(&lineno, ¤tfile); + + if (currentfile) { fprintf(error_file, "%s(%"PRId32") : ", currentfile, lineno); nasm_free(currentfile); + } else { + fputs("nasm: ", error_file); } + va_start(ap, fmt); report_error_common(severity, fmt, ap); va_end(ap); -- 2.11.4.GIT