From e84536543addf025800893824465f4944e75e343 Mon Sep 17 00:00:00 2001 From: Alain Frisch Date: Thu, 22 Dec 2011 16:04:25 +0000 Subject: [PATCH] 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 --- typing/env.ml | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/typing/env.ml b/typing/env.ml index 8d90b4732..8c00cb4c6 100644 --- a/typing/env.ml +++ b/typing/env.ml @@ -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