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/Parser/ParserFile.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lib/Parser/ParserFile.cc') diff --git a/lib/Parser/ParserFile.cc b/lib/Parser/ParserFile.cc index 99a939f..c51c7e7 100644 --- a/lib/Parser/ParserFile.cc +++ b/lib/Parser/ParserFile.cc @@ -14,7 +14,7 @@ std::unique_ptr Parser::ParseOpenFile() { if (!FileName) return nullptr; if (CurTok != tok_for) { - cps::sourceDiagnostic(Lex.getLine(), "error: Expected FOR after OPENFILE filename at line %d\n", Lex.getLine()); + cps::sourceError(Lex.getLine(), "Expected FOR after OPENFILE filename"); return nullptr; } getNextToken(); // eat FOR @@ -25,11 +25,10 @@ std::unique_ptr Parser::ParseOpenFile() { case tok_write: Mode = FileMode::Write; break; case tok_append: Mode = FileMode::Append; break; case tok_random: - cps::sourceDiagnostic(Lex.getLine(), "error: File mode RANDOM is not implemented (text files only) at line %d\n", - Lex.getLine()); + cps::sourceError(Lex.getLine(), "File mode RANDOM is not implemented (text files only)"); return nullptr; default: - cps::sourceDiagnostic(Lex.getLine(), "error: Expected file mode READ, WRITE or APPEND at line %d\n", Lex.getLine()); + cps::sourceError(Lex.getLine(), "Expected file mode READ, WRITE or APPEND"); return nullptr; } getNextToken(); // eat the mode keyword @@ -46,13 +45,13 @@ std::unique_ptr Parser::ParseReadFile() { if (!FileName) return nullptr; if (CurTok != ',') { - cps::sourceDiagnostic(Lex.getLine(), "error: Expected ',' after READFILE filename at line %d\n", Lex.getLine()); + cps::sourceError(Lex.getLine(), "Expected ',' after READFILE filename"); return nullptr; } getNextToken(); // eat ',' if (CurTok != tok_identifier) { - cps::sourceDiagnostic(Lex.getLine(), "error: Expected variable name after ',' in READFILE at line %d\n", Lex.getLine()); + cps::sourceError(Lex.getLine(), "Expected variable name after ',' in READFILE"); return nullptr; } std::string VarName = Lex.IdentifierStr; @@ -62,7 +61,7 @@ std::unique_ptr Parser::ParseReadFile() { // Consume the whole designator so it cannot replay as statements. std::vector Dummy; ParseDesignatorSuffix(Dummy); - cps::sourceDiagnostic(Lex.getLine(), "error: READFILE target must be a plain STRING variable at line %d\n", Line); + cps::sourceError(Line, "READFILE target must be a plain STRING variable"); return nullptr; } @@ -78,7 +77,7 @@ std::unique_ptr Parser::ParseWriteFile() { if (!FileName) return nullptr; if (CurTok != ',') { - cps::sourceDiagnostic(Lex.getLine(), "error: Expected ',' after WRITEFILE filename at line %d\n", Lex.getLine()); + cps::sourceError(Lex.getLine(), "Expected ',' after WRITEFILE filename"); return nullptr; } getNextToken(); // eat ',' -- cgit v1.3.1-4-g156e