aboutsummaryrefslogtreecommitdiffstats
path: root/cparser
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2017-01-30 12:33:38 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2017-01-30 12:33:38 +0100
commit88cfc534ae24986a95211038b828a1878001044c (patch)
treef7f2c4d4d65b9995b2116a78ad75be4065e0343e /cparser
parente858c84a7b2af9e7ccf4ac3268129520041210d9 (diff)
downloadcompcert-88cfc534ae24986a95211038b828a1878001044c.tar.gz
compcert-88cfc534ae24986a95211038b828a1878001044c.zip
Added support for different diagnostic formats.
The new option -fdiagnostics-format allows it to switch between the three different format version: -ccomp (default) with file:line: -vi with file+line: -msvc with file(line): Bug 19872
Diffstat (limited to 'cparser')
-rw-r--r--cparser/Cerrors.ml27
1 files changed, 25 insertions, 2 deletions
diff --git a/cparser/Cerrors.ml b/cparser/Cerrors.ml
index b8df328e..dffd9c14 100644
--- a/cparser/Cerrors.ml
+++ b/cparser/Cerrors.ml
@@ -272,10 +272,31 @@ let pp_key key fmt =
| Some s -> " ["^s^"]" in
fprintf fmt "%s%t@." key rsc
+(* Different loc output formats *)
+type loc_format =
+ | Default
+ | MSVC
+ | Vi
+
+let diagnostics_format : loc_format ref = ref Default
+
+(* Parse the option string *)
+let parse_loc_format s =
+ let s = String.sub s 21 ((String.length s) - 21) in
+ let loc_fmt = match s with
+ | "ccomp" -> Default
+ | "msvc" -> MSVC
+ | "vi" -> Vi
+ | s -> Printf.eprintf "Invalid value '%s' in '-fdiagnostics-format=%s'\n" s s; exit 2 in
+ diagnostics_format := loc_fmt
+
(* Print the location or ccomp for the case of unknown loc *)
let pp_loc fmt (filename,lineno) =
if filename <> "" && lineno <> -10 && filename <> "cabs loc unknown" then
- fprintf fmt "%t%s:%d:%t " bc filename lineno rsc
+ match !diagnostics_format with
+ | Default -> fprintf fmt "%t%s:%d:%t " bc filename lineno rsc
+ | MSVC -> fprintf fmt "%t%s(%d):%t " bc filename lineno rsc
+ | Vi -> fprintf fmt "%t%s +%d:%t " bc filename lineno rsc
else
fprintf fmt "%tccomp:%t " bc rsc
@@ -355,7 +376,9 @@ let warning_options =
Exact ("-w"), Unit wnothing;
longopt_int ("-fmax-errors") ((:=) max_error);
Exact("-fno-diagnostics-show-option"),Unset diagnostics_show_option;
- Exact("-fdiagnostics-show-option"),Set diagnostics_show_option;]
+ Exact("-fdiagnostics-show-option"),Set diagnostics_show_option;
+ _Regexp("-fdiagnostics-format=\\(ccomp\\|msvc\\|vi\\)"),Self parse_loc_format;
+ ]
let warning_help = {|Diagnostic options:
-Wall Enable all warnings