1 (* *********************************************************************)
3 (* The Compcert verified compiler *)
5 (* Xavier Leroy, INRIA Paris-Rocquencourt *)
7 (* Copyright Institut National de Recherche en Informatique et en *)
8 (* Automatique. All rights reserved. This file is distributed *)
9 (* under the terms of the GNU General Public License as published by *)
10 (* the Free Software Foundation, either version 2 of the License, or *)
11 (* (at your option) any later version. This file is also distributed *)
12 (* under the terms of the INRIA Non-Commercial License Agreement. *)
14 (* *********************************************************************)
16 (* Management of errors and warnings *)
20 let warn_error = ref false
22 let num_errors = ref 0
23 let num_warnings = ref 0
25 let reset () = num_errors := 0; num_warnings := 0
32 (fun _ -> raise Abort)
34 ("@[<hov 2>" ^^ fmt ^^ ".@]@.@[<hov 0>Fatal error.@]@.")
38 eprintf ("@[<hov 2>" ^^ fmt ^^ ".@]@.")
42 eprintf ("@[<hov 2>" ^^ fmt ^^ ".@]@.")
45 if !num_errors > 0 then
46 eprintf "@[<hov 0>%d error%s detected.@]@."
48 (if !num_errors = 1 then "" else "s");
49 if !warn_error && !num_warnings > 0 then
50 eprintf "@[<hov 0>%d error-enabled warning%s detected.@]@."
52 (if !num_warnings = 1 then "" else "s");
53 !num_errors > 0 || (!warn_error && !num_warnings > 0)