aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2018-02-09 09:53:12 +0100
committerBernhard Schommer <bernhardschommer@gmail.com>2018-02-09 09:53:12 +0100
commit857e746959f1eb9d0158073114d5ae0aa1c2fc1f (patch)
tree63e38025de7e855da2e3aec1a5220de03313dd1d
parentd8da506981905752f84165f622fdf0ee26011744 (diff)
downloadcompcert-kvx-857e746959f1eb9d0158073114d5ae0aa1c2fc1f.tar.gz
compcert-kvx-857e746959f1eb9d0158073114d5ae0aa1c2fc1f.zip
Added error summary in case of fatal error.
-rw-r--r--cparser/Diagnostics.ml10
-rw-r--r--cparser/Diagnostics.mli3
-rw-r--r--driver/Driver.ml2
3 files changed, 14 insertions, 1 deletions
diff --git a/cparser/Diagnostics.ml b/cparser/Diagnostics.ml
index d9b96393..fbdc9297 100644
--- a/cparser/Diagnostics.ml
+++ b/cparser/Diagnostics.ml
@@ -342,14 +342,24 @@ let error loc fmt =
let fatal_error loc fmt =
fatal_error None loc fmt
+let error_summary () =
+ if !num_errors > 0 then begin
+ eprintf "@[<hov 0>%d error%s detected.@]@."
+ !num_errors
+ (if !num_errors = 1 then "" else "s");
+ num_errors := 0;
+ end
+
let check_errors () =
if !num_errors > 0 then begin
eprintf "@[<hov 0>%d error%s detected.@]@."
!num_errors
(if !num_errors = 1 then "" else "s");
+ num_errors := 0;
raise Abort
end
+
let error_option w =
let key = string_of_warning w in
[Exact ("-W"^key), Unit (activate_warning w);
diff --git a/cparser/Diagnostics.mli b/cparser/Diagnostics.mli
index 54395136..82edd9fa 100644
--- a/cparser/Diagnostics.mli
+++ b/cparser/Diagnostics.mli
@@ -84,3 +84,6 @@ val no_loc : string * int
val file_loc : string -> string * int
(** [file_loc f] generates a location for file [f] *)
+
+val error_summary : unit -> unit
+(** Print a summary containing the numbers of errors encountered *)
diff --git a/driver/Driver.ml b/driver/Driver.ml
index 9c9f2d79..0ad820ea 100644
--- a/driver/Driver.ml
+++ b/driver/Driver.ml
@@ -415,5 +415,5 @@ let _ =
with
| Sys_error msg
| CmdError msg -> error no_loc "%s" msg; exit 2
- | Abort -> exit 2
+ | Abort -> error_summary (); exit 2
| e -> crash e