diff options
Diffstat (limited to 'cparser')
-rw-r--r-- | cparser/Cerrors.ml | 6 | ||||
-rw-r--r-- | cparser/Cerrors.mli | 1 | ||||
-rw-r--r-- | cparser/Elab.ml | 7 | ||||
-rw-r--r-- | cparser/Parse.ml | 1 |
4 files changed, 12 insertions, 3 deletions
diff --git a/cparser/Cerrors.ml b/cparser/Cerrors.ml index 5c077f37..a4d1a3f8 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_errors > 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 76f8efdb..8cd7ed64 100644 --- a/cparser/Elab.ml +++ b/cparser/Elab.ml @@ -433,6 +433,7 @@ let elab_attribute env = function begin match elab_attr_arg loc env a with | AInt n when is_power_of_two n -> [AAlignas (Int64.to_int n)] | _ -> warning loc "bad _Alignas value, ignored"; [] + | exception Wrong_attr_arg -> warning loc "bad _Alignas value, ignored"; [] end | ALIGNAS_ATTR (_, loc) -> warning loc "_Alignas takes exactly one parameter, ignored"; [] @@ -812,7 +813,11 @@ and elab_struct_or_union_info kind loc env members attrs = check_incomplete m; (* Warn for empty structs or unions *) if m = [] then - warning loc "empty %s" (if kind = Struct then "struct" else "union"); + if kind = Struct then begin + warning loc "empty struct" + end else begin + fatal_error loc "empty union" + end; (composite_info_def env' kind attrs m, env') and elab_struct_or_union only kind loc tag optmembers attrs env = 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 -> |