From b4ffb2d9498560557821714e2d4651279dd6817c Mon Sep 17 00:00:00 2001 From: _ov4 Date: Wed, 21 Oct 2026 14:03:31 +0000 Subject: feat(diagnostics): print source diagnostics in gcc file:line: layout Lexer, parser, driver and codegen diagnostics now read ":: error: " instead of "error: at line N in ". The path is always printed as given on the command line. Call sites pass the bare message to cps::sourceError/sourceWarning, which carry printf format checking; reportError routes through the same helper. The suite iii harness parses the new layout and matches the reason against the message only. iii/template-class-pack-field passed only because its reason regex matched the case path, so it is now case-insensitive. Co-Authored-By: Claude Opus 5.5 --- lib/CodeGen/CodeGen.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'lib/CodeGen/CodeGen.cc') diff --git a/lib/CodeGen/CodeGen.cc b/lib/CodeGen/CodeGen.cc index fb86120..e184b19 100644 --- a/lib/CodeGen/CodeGen.cc +++ b/lib/CodeGen/CodeGen.cc @@ -28,10 +28,7 @@ bool CodeGen::isBuiltinName(const std::string &Name) { void CodeGen::reportError(const char *Fmt, ...) { va_list Args; va_start(Args, Fmt); - fprintf(stderr, "error: "); - vfprintf(stderr, Fmt, Args); - if (DiagnosticLine) fprintf(stderr, "%s", lineSuffix(DiagnosticLine).c_str()); - fprintf(stderr, "\n"); + cps::vsourceDiagnostic(cps::Severity::Error, DiagnosticLine, Fmt, Args); va_end(Args); HadError = true; } @@ -154,7 +151,7 @@ bool CodeGen::isVisible(size_t Owner) const { void CodeGen::selectUnit(size_t Unit) { CurrentUnit = Unit; - DiagnosticSource = Units->size() > 1 ? (*Units)[Unit].Path : ""; + DiagnosticSource = (*Units)[Unit].Path; FuncGen->setCurrentUnit(Unit, (*Units)[Unit].Path); RuntimeChecker->setLibraryMode((*Units)[Unit].IsLibrary); FuncGen->setCallHook([this](const FuncSig &Sig) { -- cgit v1.3.1-4-g156e