aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2016-08-08 10:37:53 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2016-08-08 10:37:53 +0200
commit8228d4f959c2211d1840928d1cfc349ce2820200 (patch)
tree01e9da05ca158ea53b447c67983058a25eb88d0d
parentb184e05aada74f34dafd9d1bf6bc24e68ab76e05 (diff)
downloadcompcert-kvx-8228d4f959c2211d1840928d1cfc349ce2820200.tar.gz
compcert-kvx-8228d4f959c2211d1840928d1cfc349ce2820200.zip
Added error check before transformations.
Added a check for errors after the elab phases to avoid problems in the transformations due to broken input programs. Bug 19504
-rw-r--r--cparser/Cerrors.ml6
-rw-r--r--cparser/Cerrors.mli1
-rw-r--r--cparser/Elab.ml2
-rw-r--r--cparser/Parse.ml1
4 files changed, 7 insertions, 3 deletions
diff --git a/cparser/Cerrors.ml b/cparser/Cerrors.ml
index 5c077f37..0667ea16 100644
--- a/cparser/Cerrors.ml
+++ b/cparser/Cerrors.ml
@@ -30,7 +30,7 @@ exception Abort
to print its message, as opposed to [Format], and does not automatically
introduce indentation and a final dot into the message. This is useful
for multi-line messages. *)
-
+
let fatal_error_raw fmt =
incr num_errors;
Printf.kfprintf
@@ -67,4 +67,6 @@ let check_errors () =
(if !num_warnings = 1 then "" else "s");
!num_errors > 0 || (!warn_error && !num_warnings > 0)
-
+let raise_on_errors () =
+ if !num_warnings > 0 || (!warn_error && !num_warnings > 0) then
+ raise Abort
diff --git a/cparser/Cerrors.mli b/cparser/Cerrors.mli
index 3e315fad..313573c3 100644
--- a/cparser/Cerrors.mli
+++ b/cparser/Cerrors.mli
@@ -22,3 +22,4 @@ val error : ('a, Format.formatter, unit, unit, unit, unit) format6 -> 'a
val warning : ('a, Format.formatter, unit, unit, unit, unit) format6 -> 'a
val info : ('a, Format.formatter, unit, unit, unit, unit) format6 -> 'a
val check_errors : unit -> bool
+val raise_on_errors : unit -> unit
diff --git a/cparser/Elab.ml b/cparser/Elab.ml
index 67b23d91..76f8efdb 100644
--- a/cparser/Elab.ml
+++ b/cparser/Elab.ml
@@ -2361,7 +2361,7 @@ let rec elab_stmt env ctx s =
instead of the expected type@ %a"
Cprint.typ b.etyp Cprint.typ ctx.ctx_return_typ
else
- fatal_error loc
+ error loc
"return value has type@ %a@ \
instead of the expected type@ %a"
Cprint.typ b.etyp Cprint.typ ctx.ctx_return_typ
diff --git a/cparser/Parse.ml b/cparser/Parse.ml
index c125e653..3f60ebb4 100644
--- a/cparser/Parse.ml
+++ b/cparser/Parse.ml
@@ -74,6 +74,7 @@ let preprocessed_file transfs name sourcefile =
| Parser.Parser.Inter.Timeout_pr -> assert false
| Parser.Parser.Inter.Parsed_pr (ast, _ ) -> ast) in
let p1 = Timing.time "Elaboration" Elab.elab_file ast in
+ Cerrors.raise_on_errors ();
Timing.time2 "Emulations" transform_program t p1 name
with
| Cerrors.Abort ->