diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-21 14:03:31 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-21 14:03:31 +0000 |
| commit | b4ffb2d9498560557821714e2d4651279dd6817c (patch) | |
| tree | 995ad02bdb8cc461f48a53683c4fd7f2ddd8656b /lib/Parser/ParserFile.cc | |
| parent | f1f5fa394a67a789914ccf2b24d534a0e466ae1b (diff) | |
feat(diagnostics): print source diagnostics in gcc file:line: layout
Lexer, parser, driver and codegen diagnostics now read
"<path>:<line>: error: <message>" instead of "error: <message> at line N
in <path>". 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 <noreply@anthropic.com>
Diffstat (limited to 'lib/Parser/ParserFile.cc')
| -rw-r--r-- | lib/Parser/ParserFile.cc | 15 |
1 files changed, 7 insertions, 8 deletions
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<StmtAST> 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<StmtAST> 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<StmtAST> 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<StmtAST> Parser::ParseReadFile() { // Consume the whole designator so it cannot replay as statements. std::vector<DesignatorAccess> 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<StmtAST> 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 ',' |
