From 7165b2980954610712b136c42f55f7429ad332d4 Mon Sep 17 00:00:00 2001 From: mrdudz Date: Thu, 14 Jul 2022 22:54:18 +0200 Subject: [PATCH] omit an error message also when an unresolved import was added by the compiler. fixes bug #1551 --- src/ld65/exports.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/ld65/exports.c b/src/ld65/exports.c index 35de5c8f2..9149f54d1 100644 --- a/src/ld65/exports.c +++ b/src/ld65/exports.c @@ -776,14 +776,20 @@ static void PrintUnresolved (ExpCheckFunc F, void* Data) Import* Imp = E->ImpList; const char* name = GetString (E->Name); while (Imp) { - unsigned J; - for (J = 0; J < CollCount (&Imp->RefLines); ++J) { - const LineInfo* LI = CollConstAt (&Imp->RefLines, J); - fprintf (stderr, - "%s:%u: Error: Unresolved external '%s'\n", - GetSourceName (LI), - GetSourceLine (LI), - name); + unsigned J, count = CollCount (&Imp->RefLines); + /* The count is 0 when the import was not added by an input file, + but by the compiler itself. */ + if (count == 0) { + fprintf (stderr, "Error: Unresolved external '%s'\n", name); + } else { + for (J = 0; J < count; ++J) { + const LineInfo* LI = CollConstAt (&Imp->RefLines, J); + fprintf (stderr, + "%s:%u: Error: Unresolved external '%s'\n", + GetSourceName (LI), + GetSourceLine (LI), + name); + } } Imp = Imp->Next; }