let add_warning ?(severe=false) ?source ~reason effect =
let f _ =
let msg = Format.flush_str_formatter () in
let wrn = {
Wpo.wrn_loc = Log.get_current_source () ;
Wpo.wrn_severe = severe ;
Wpo.wrn_source = (match source with None -> "wp" | Some r -> r) ;
Wpo.wrn_reason = reason ;
Wpo.wrn_effect = msg ;
} in
match !stack with
| top::_ -> top.c_warning <- wrn::top.c_warning
| _ -> Wp_parameters.fatal "Datalib.Collector: empty stack"
in Format.kfprintf f Format.str_formatter effect