diff --git a/include/link/warning.hpp b/include/link/warning.hpp index 96760d6f..7e7edd5f 100644 --- a/include/link/warning.hpp +++ b/include/link/warning.hpp @@ -5,15 +5,19 @@ #include +#define warningAt(where, ...) warning(where.src, where.lineNo, __VA_ARGS__) +#define errorAt(where, ...) error(where.src, where.lineNo, __VA_ARGS__) +#define fatalAt(where, ...) fatal(where.src, where.lineNo, __VA_ARGS__) + struct FileStackNode; [[gnu::format(printf, 3, 4)]] -void warning(FileStackNode const *where, uint32_t lineNo, char const *fmt, ...); +void warning(FileStackNode const *src, uint32_t lineNo, char const *fmt, ...); [[gnu::format(printf, 1, 2)]] void warning(char const *fmt, ...); [[gnu::format(printf, 3, 4)]] -void error(FileStackNode const *where, uint32_t lineNo, char const *fmt, ...); +void error(FileStackNode const *src, uint32_t lineNo, char const *fmt, ...); [[gnu::format(printf, 1, 2)]] void error(char const *fmt, ...); [[gnu::format(printf, 1, 2)]] @@ -22,7 +26,7 @@ void errorNoDump(char const *fmt, ...); void argErr(char flag, char const *fmt, ...); [[gnu::format(printf, 3, 4), noreturn]] -void fatal(FileStackNode const *where, uint32_t lineNo, char const *fmt, ...); +void fatal(FileStackNode const *src, uint32_t lineNo, char const *fmt, ...); [[gnu::format(printf, 1, 2), noreturn]] void fatal(char const *fmt, ...); diff --git a/src/link/patch.cpp b/src/link/patch.cpp index c5f5ae49..323ae8b8 100644 --- a/src/link/patch.cpp +++ b/src/link/patch.cpp @@ -35,7 +35,7 @@ static bool isError = false; static int32_t popRPN(Patch const &patch) { if (rpnStack.empty()) { - fatal(patch.src, patch.lineNo, "Internal error, RPN stack empty"); + fatalAt(patch, "Internal error, RPN stack empty"); } RPNStackEntry entry = rpnStack.front(); @@ -49,7 +49,7 @@ static int32_t popRPN(Patch const &patch) { static uint32_t getRPNByte(uint8_t const *&expression, int32_t &size, Patch const &patch) { if (!size--) { - fatal(patch.src, patch.lineNo, "Internal error, RPN expression overread"); + fatalAt(patch, "Internal error, RPN expression overread"); } return *expression++; @@ -99,7 +99,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector const &fil value = popRPN(patch); if (value == 0) { if (!isError) { - error(patch.src, patch.lineNo, "Division by 0"); + errorAt(patch, "Division by 0"); isError = true; } popRPN(patch); @@ -112,7 +112,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector const &fil value = popRPN(patch); if (value == 0) { if (!isError) { - error(patch.src, patch.lineNo, "Modulo by 0"); + errorAt(patch, "Modulo by 0"); isError = true; } popRPN(patch); @@ -128,7 +128,7 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector const &fil value = popRPN(patch); if (value < 0) { if (!isError) { - error(patch.src, patch.lineNo, "Exponent by negative value %" PRId32, value); + errorAt(patch, "Exponent by negative value %" PRId32, value); isError = true; } popRPN(patch); @@ -222,9 +222,8 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector const &fil } if (Symbol const *symbol = getSymbol(fileSymbols, value); !symbol) { - error( - patch.src, - patch.lineNo, + errorAt( + patch, "Requested BANK() of symbol \"%s\", which was not found", fileSymbols[value].name.c_str() ); @@ -233,9 +232,8 @@ static int32_t computeRPNExpr(Patch const &patch, std::vector const &fil } else if (std::holds_alternative