harec

[hare] Hare compiler, written in C11 for POSIX OSs
Log | Files | Refs | README | LICENSE

commit 4730fa6b835f08c44bd7991cc8b264fbc27d752b
parent 375d1d2d7d0358da55a02242efd184bb94e63698
Author: Bor Grošelj Simić <bgs@turminal.net>
Date:   Wed,  8 Feb 2023 05:21:58 +0100

make it clear when error location is unknown

A small usability improvement. Unknown locations were previously
reported as "-D:0:0", which is now replaced by "<unknown>:0:0".

Signed-off-by: Bor Grošelj Simić <bgs@turminal.net>

Diffstat:
Msrc/check.c | 2++
Msrc/main.c | 2+-
2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/check.c b/src/check.c @@ -4231,6 +4231,7 @@ check_internal(struct type_store *ts, // sub-scopes for each declaration, expression-list, etc. // Put defines into a temporary scope (-D on the command line) + sources[0] = "-D"; ctx.scope = NULL; ctx.unit = scope_push(&ctx.scope, SCOPE_DEFINES); for (struct ast_global_decl *def = defines; def; def = def->next) { @@ -4241,6 +4242,7 @@ check_internal(struct type_store *ts, ctx.defines = ctx.scope; ctx.scope = NULL; ctx.defines->parent = ctx.unit = scope_push(&ctx.scope, SCOPE_UNIT); + sources[0] = "<unknown>"; // Populate the imports and put declarations into a scope. // Each declaration holds a reference to its subunit's imports diff --git a/src/main.c b/src/main.c @@ -143,7 +143,7 @@ main(int argc, char *argv[]) sources = xcalloc(ninputs + 2, sizeof(char **)); memcpy((char **)sources + 1, argv + optind, sizeof(char **) * ninputs); - sources[0] = "-D"; + sources[0] = "<unknown>"; sources[ninputs + 1] = NULL; for (size_t i = 0; i < ninputs; ++i) {