diff options
author | Xavier Leroy <xavier.leroy@inria.fr> | 2014-12-30 12:54:43 +0100 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@inria.fr> | 2014-12-30 12:54:43 +0100 |
commit | e6b5004af0960958aab6cbdc9f24a06f00d104eb (patch) | |
tree | f7b38227b108dc60b3e036180b166f153157de6b | |
parent | 7cce5af2b184bbb7b037b2a32793c7bfa287da72 (diff) | |
download | compcert-e6b5004af0960958aab6cbdc9f24a06f00d104eb.tar.gz compcert-e6b5004af0960958aab6cbdc9f24a06f00d104eb.zip |
Improve printing of errors.
-rw-r--r-- | cparser/Env.ml | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/cparser/Env.ml b/cparser/Env.ml index 355a9960..6610c159 100644 --- a/cparser/Env.ml +++ b/cparser/Env.ml @@ -266,16 +266,24 @@ let add_enum env id info = open Printf +let composite_tag_name name = + if name = "" then "<anonymous>" else name + let error_message = function | Unbound_identifier name -> sprintf "Unbound identifier '%s'" name | Unbound_tag(name, kind) -> - sprintf "Unbound %s '%s'" kind name + sprintf "Unbound %s '%s'" kind (composite_tag_name name) | Tag_mismatch(name, expected, actual) -> sprintf "'%s' was declared as a %s but is used as a %s" - name actual expected + (composite_tag_name name) actual expected | Unbound_typedef name -> sprintf "Unbound typedef '%s'" name | No_member(compname, compkind, memname) -> sprintf "%s '%s' has no member named '%s'" - compkind compname memname + compkind (composite_tag_name compname) memname + +let _ = + Printexc.register_printer + (function Error e -> Some (sprintf "Env.Error \"%s\"" (error_message e)) + | _ -> None) |