Commit 061863e1 authored by Pietro Abate's avatar Pietro Abate
Browse files

[r2003-05-25 12:20:16 by cvscast] No warning for embedded unused branches

Original author: cvscast
Date: 2003-05-25 12:20:16+00:00
parent 9bd487ed
......@@ -537,7 +537,9 @@ let pat p =
module Fv = IdSet
let all_branches = ref []
type branch = Branch of Typed.branch * branch list
let cur_branch : branch list ref = ref []
let exp loc fv e =
fv,
......@@ -636,6 +638,8 @@ let rec expr loc = function
let fv = ref Fv.empty in
let accept = ref Types.empty in
let branch (p,e) =
let cur_br = !cur_branch in
cur_branch := [];
let (fv2,e) = expr noloc e in
let br_loc = merge_loc p.loc e.Typed.exp_loc in
let p = pat p in
......@@ -648,7 +652,7 @@ let rec expr loc = function
Typed.br_used = br_loc = noloc;
Typed.br_pat = p;
Typed.br_body = e } in
all_branches := br :: !all_branches;
cur_branch := Branch (br, !cur_branch) :: cur_br;
br in
let b = List.map branch b in
(!fv,
......@@ -935,9 +939,17 @@ and type_rec_funs env l =
| _ -> assert false) l;
types
let report_unused_branches () =
let rec unused_branches b =
List.iter
(fun b -> if not b.br_used then warning b.br_loc "This branch is not used")
!all_branches;
all_branches := []
(fun (Branch (br,s)) ->
if not br.br_used
then warning br.br_loc "This branch is not used"
else unused_branches s
)
b
let report_unused_branches () =
unused_branches !cur_branch;
cur_branch := []
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment