The implicit type created by class and class types definitions is marked as used when the class or class type are referenced.

git-svn-id: http://caml.inria.fr/svn/ocaml/branches/unused_declarations@11941 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Alain Frisch 2011-12-22 16:04:25 +00:00
parent 85a99d7bd4
commit e84536543a
1 changed files with 17 additions and 6 deletions

View File

@ -524,12 +524,13 @@ let lookup_type lid env =
mark_type_used (Longident.last lid) desc;
r
let mark_type_path env path =
let decl = try find_type path env with Not_found -> assert false in
mark_type_used (Path.name path) decl
let mark_type_constr env = function
| {desc=Tconstr(path, _, _)} ->
let decl = try find_type path env with Not_found -> assert false in
mark_type_used (Path.name path) decl
| _ ->
assert false
| {desc=Tconstr(path, _, _)} -> mark_type_path env path
| _ -> assert false
let lookup_constructor lid env =
let desc = lookup_constructor lid env in
@ -541,6 +542,16 @@ let lookup_label lid env =
mark_type_constr env desc.lbl_res;
desc
let lookup_class lid env =
let (_, desc) as r = lookup_class lid env in
mark_type_path env desc.cty_path;
r
let lookup_cltype lid env =
let (_, desc) as r = lookup_cltype lid env in
mark_type_path env desc.clty_path;
r
(* GADT instance tracking *)
let add_gadt_instance_level lv env =
@ -770,7 +781,7 @@ and check_usage loc id warn tbl =
Hashtbl.add tbl key (fun () -> used := true);
!add_delayed_check_forward
(fun () ->
if not (name = "" || name.[0] = '_' || !used) then begin
if not (name = "" || name.[0] = '_' || name.[0] = '#' || !used) then begin
used := true;
Location.prerr_warning loc (warn name)
end