Error messages refer to "undefined" symbols and sections

This commit is contained in:
Rangi42
2025-08-08 19:22:13 -04:00
parent 9fc83efe06
commit 2130a5ba1f
38 changed files with 86 additions and 79 deletions

View File

@@ -594,9 +594,9 @@ std::string act_SectionName(std::string const &symName) {
Symbol *sym = sym_FindScopedValidSymbol(symName);
if (!sym) {
if (sym_IsPurgedScoped(symName)) {
fatal("Unknown symbol \"%s\"; it was purged", symName.c_str());
fatal("Undefined symbol \"%s\"; it was purged", symName.c_str());
} else {
fatal("Unknown symbol \"%s\"", symName.c_str());
fatal("Undefined symbol \"%s\"", symName.c_str());
}
}

View File

@@ -370,9 +370,9 @@ void fstk_RunMacro(std::string const &macroName, std::shared_ptr<MacroArgs> macr
if (!macro) {
if (sym_IsPurgedExact(macroName)) {
error("Macro \"%s\" not defined; it was purged", macroName.c_str());
error("Undefined macro \"%s\"; it was purged", macroName.c_str());
} else {
error("Macro \"%s\" not defined", macroName.c_str());
error("Undefined macro \"%s\"", macroName.c_str());
}
return;
}

View File

@@ -579,7 +579,7 @@ static uint32_t readBracketedMacroArgNum() {
c = bumpChar();
if (c != '>') {
error("Invalid character in bracketed macro argument %s", printChar(c));
error("Invalid character %s in bracketed macro argument", printChar(c));
return 0;
} else if (empty) {
error("Empty bracketed macro argument");
@@ -911,7 +911,7 @@ static void discardLineContinuation() {
error("Invalid line continuation at end of file");
break;
} else {
error("Invalid character after line continuation %s", printChar(c));
error("Invalid character %s after line continuation", printChar(c));
break;
}
}
@@ -1568,17 +1568,19 @@ static bool isGarbageCharacter(int c) {
static void reportGarbageCharacters(int c) {
// '#' can be garbage if it doesn't start a raw string or identifier
assume(isGarbageCharacter(c) || c == '#');
bool isAscii = isPrintable(c);
if (isGarbageCharacter(peek())) {
// At least two characters are garbage; group them into one error report
std::string garbage = printChar(c);
while (isGarbageCharacter(peek())) {
c = bumpChar();
isAscii &= isPrintable(c);
garbage += ", ";
garbage += printChar(c);
}
error("Unknown characters %s", garbage.c_str());
error("Invalid characters %s%s", garbage.c_str(), isAscii ? "" : " (is the file UTF-8?)");
} else {
error("Unknown character %s", printChar(c));
error("Invalid character %s%s", printChar(c), isAscii ? "" : " (is the file UTF-8?)");
}
}

View File

@@ -284,9 +284,9 @@ void sym_Purge(std::string const &symName) {
if (!sym) {
if (sym_IsPurgedScoped(symName)) {
error("'%s' was already purged", symName.c_str());
error("Undefined symbol '%s' was already purged", symName.c_str());
} else {
error("'%s' not defined", symName.c_str());
error("Undefined symbol '%s'", symName.c_str());
}
} else if (sym->isBuiltin) {
error("Built-in symbol '%s' cannot be purged", symName.c_str());