diff options
author | Bernhard Schommer <bernhardschommer@gmail.com> | 2017-01-27 11:08:30 +0100 |
---|---|---|
committer | Bernhard Schommer <bernhardschommer@gmail.com> | 2017-01-27 11:08:30 +0100 |
commit | 0c4df88bc2bfc717c39ff8cc60b30f47f4a83867 (patch) | |
tree | 3cc01d5ea15951dfd75ff0f4496e990671047610 | |
parent | 48aa7e9385ce265d51e8b75fb6e583c682201c54 (diff) | |
download | compcert-0c4df88bc2bfc717c39ff8cc60b30f47f4a83867.tar.gz compcert-0c4df88bc2bfc717c39ff8cc60b30f47f4a83867.zip |
Added -f(no-)diagnostics-show-option.
Controls whether the [-Woption] is printed in the diagnostic
message for mappable warnings/errors.
Bug 19872
-rw-r--r-- | cparser/Cerrors.ml | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/cparser/Cerrors.ml b/cparser/Cerrors.ml index 57d36b25..23053096 100644 --- a/cparser/Cerrors.ml +++ b/cparser/Cerrors.ml @@ -24,6 +24,8 @@ let error_fatal = ref false (* Maximum number of errors, 0 means unlimited *) let max_error = ref 0 +(* Whether [-Woption] should be printed *) +let diagnostics_show_option = ref true (* Test if color diagnostics are available by testing if stderr is a tty and if the environment varibale TERM is set @@ -211,12 +213,19 @@ let werror () = let key_of_warning w = match w with | Unnamed -> None - | _ -> Some ("-W"^(string_of_warning w)) + | _ -> if !diagnostics_show_option then + Some ("-W"^(string_of_warning w)) + else + None (* Add -Werror to the printed keys *) -let key_add_werror = function - | None -> Some ("-Werror") - | Some s -> Some ("-Werror,"^s) +let key_add_werror w = + if !diagnostics_show_option then + None + else + match w with + | None -> Some ("-Werror") + | Some s -> Some ("-Werror,"^s) (* Lookup how to print the warning *) let classify_warning w = @@ -344,7 +353,9 @@ let warning_options = Exact ("-Werror"), Unit werror; Exact ("-Wall"), Unit wall; Exact ("-w"), Unit wnothing; - longopt_int ("-fmax-errors") ((:=) max_error);] + longopt_int ("-fmax-errors") ((:=) max_error); + Exact("-fno-diagnostics-show-option"),Unset diagnostics_show_option; + Exact("-fdiagnostics-show-option"),Set diagnostics_show_option;] let warning_help = {|Diagnostic options: -Wall Enable all warnings @@ -356,8 +367,11 @@ let warning_help = {|Diagnostic options: specified -Wfatal-errors Turn all errors into fatal errors aborting the compilation -fdiagnostics-color Turn on colored diagnostics - -fmax-errors=<n> Maximum number of errors to report -fno-diagnostics-color Turn of colored diagnostics + -fmax-errors=<n> Maximum number of errors to report + -fdiagnostics-show-option Print the option name with mappable diagnostics + -fno-diagnostics-show-option Turn of printing of options with mappable + diagnostics |} let raise_on_errors () = |