Refactor warnings and errors (#1728)

* Remove `err` and `warn`, keep `errx` and `warnx`, using them in RGBGFX too

* Separate RGBGFX and RGBLINK warnings/errors from main options

* Separate `report` function into `error` and `fatal` messages

* Implicit newlines for most RGBASM errors
This commit is contained in:
Rangi
2025-07-08 12:58:23 -04:00
committed by GitHub
parent 991b74dd0d
commit 35962dedc4
39 changed files with 753 additions and 757 deletions

View File

@@ -65,7 +65,7 @@ Diagnostics<WarningLevel, WarningID> warnings = {
};
// clang-format on
void printDiag(
static void printDiag(
char const *fmt, va_list args, char const *type, char const *flagfmt, char const *flag
) {
fputs(type, stderr);
@@ -74,6 +74,7 @@ void printDiag(
fprintf(stderr, flagfmt, flag);
fputs("\n ", stderr);
vfprintf(stderr, fmt, args);
putc('\n', stderr);
lexer_DumpStringExpansions();
}
@@ -96,6 +97,28 @@ void error(char const *fmt, ...) {
}
}
void errorNoNewline(char const *fmt, ...) {
va_list args;
fputs("error: ", stderr);
fstk_DumpCurrent();
fputs(":\n ", stderr);
va_start(args, fmt);
vfprintf(stderr, fmt, args);
va_end(args);
// This intentionally makes 0 act as "unlimited" (or at least "limited to sizeof(unsigned)")
nbErrors++;
if (nbErrors == maxErrors) {
errx(
"The maximum of %u error%s was reached (configure with \"-X/--max-errors\"); assembly "
"aborted!",
maxErrors,
maxErrors == 1 ? "" : "s"
);
}
}
[[noreturn]]
void fatalerror(char const *fmt, ...) {
va_list args;