From 899c2af576124df2918fd2ae976434df0ebbae5b Mon Sep 17 00:00:00 2001 From: _ov4 Date: Wed, 21 Oct 2026 14:06:54 +0000 Subject: feat(driver): color diagnostics like gcc with -fdiagnostics-color Add -fdiagnostics-color[=auto|always|never] and -fno-diagnostics-color. The default auto mode colors only a terminal stderr (TERM set and not dumb on Unix; a console that accepts VT sequences on Windows), so test harnesses, the desktop bundle and other pipes stay plain. Every diagnostic label now comes from cps::diagnosticPrefix, which emits gcc's default GCC_COLORS bytes: bold locus, bold red error/fatal error, bold magenta warning, bold cyan note. compilation terminated., runtime messages of the compiled program and lld output are unchanged. Co-Authored-By: Claude Opus 5.5 --- include/cps/Diagnostics.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'include/cps') diff --git a/include/cps/Diagnostics.h b/include/cps/Diagnostics.h index 3492f46..4bcb877 100644 --- a/include/cps/Diagnostics.h +++ b/include/cps/Diagnostics.h @@ -9,13 +9,25 @@ enum class Severity { Error, Warning, Note, Fatal }; // Path of the unit being diagnosed, as given on the command line. inline std::string DiagnosticSource; +// Set by the driver from -fdiagnostics-color. +inline bool DiagnosticColors = false; + // gcc layout: ":