diff --git a/src/plugins/e-acsl/typing.ml b/src/plugins/e-acsl/typing.ml index 556981d303a53f69c2f46661216814cd5e8dbc62..f03b128958dff04d84e50e294a364481ae06107f 100644 --- a/src/plugins/e-acsl/typing.ml +++ b/src/plugins/e-acsl/typing.ml @@ -477,42 +477,53 @@ let rec type_term ~use_gmp_opt ?(arith_operand=false) ?ctx t = dup Other | Tapp(li, _, args) -> - List.iter - (fun arg -> ignore (type_term ~use_gmp_opt:true arg)) - args; - begin match li.l_body with - | LBpred _ -> - (* We can have an [LBpred] here because we transformed - [Papp] into [Tapp] *) - dup c_int - | LBterm _ -> - begin match li.l_type with - | None -> - assert false - | Some lty -> - begin match lty with - | Linteger -> - let i = Interval.infer t in - if Options.Gmp_only.get () then dup Gmp - else dup (ty_of_interv i) - | Ctype TInt(ik, _ ) -> - dup (C_type ik) - | Ctype TFloat _ -> (* TODO: handle in MR !226 *) - dup Other - | Lreal -> - Error.not_yet "real numbers" - | Ctype _ -> - dup Other - | Ltype _ | Lvar _ | Larrow _ -> - Options.fatal "unexpected type" + if Builtins.mem li.l_var_info.lv_name then + let typ_arg lvi arg = + (* a built-in is a C function, so the context is necessarily a C + type. *) + let ctx = ty_of_logic_ty lvi.lv_type in + ignore (type_term ~use_gmp_opt:false ~ctx arg) + in + List.iter2 typ_arg li.l_profile args; + (* [li.l_type is [None] for predicate only: not possible here. + Thus using [Extlib.the] is fine *) + dup (ty_of_logic_ty (Extlib.the li.l_type)) + else begin + List.iter + (fun arg -> ignore (type_term ~use_gmp_opt:true arg)) + args; + match li.l_body with + | LBpred _ -> + (* We can have an [LBpred] here because we transformed + [Papp] into [Tapp] *) + dup c_int + | LBterm _ -> + begin match li.l_type with + | None -> + assert false + | Some lty -> + match lty with + | Linteger -> + let i = Interval.infer t in + if Options.Gmp_only.get () then dup Gmp + else dup (ty_of_interv i) + | Ctype TInt(ik, _ ) -> + dup (C_type ik) + | Ctype TFloat _ -> (* TODO: handle in MR !226 *) + dup Other + | Lreal -> + Error.not_yet "real numbers" + | Ctype _ -> + dup Other + | Ltype _ | Lvar _ | Larrow _ -> + Options.fatal "unexpected type" end - end - | LBnone -> - Error.not_yet "logic functions with no definition nor reads clause" - | LBreads _ -> - Error.not_yet "logic functions performing read accesses" - | LBinductive _ -> - Error.not_yet "logic functions inductively defined" + | LBnone -> + Error.not_yet "logic functions with no definition nor reads clause" + | LBreads _ -> + Error.not_yet "logic functions performing read accesses" + | LBinductive _ -> + Error.not_yet "logic functions inductively defined" end | Tunion _ -> Error.not_yet "tset union" diff --git a/src/plugins/e-acsl/visit.ml b/src/plugins/e-acsl/visit.ml index c12c5699c343b62d1e894370d62c7611a80c9758..4770fa319570872f11e042cfee0aa14d70f2c1b1 100644 --- a/src/plugins/e-acsl/visit.ml +++ b/src/plugins/e-acsl/visit.ml @@ -470,8 +470,9 @@ you must call function `%s' and `__e_acsl_memory_clean by yourself.@]" Cil.JustCopyPost (fun l -> let new_vi = Cil.get_varinfo self#behavior vi in - Misc.register_library_function new_vi; - Builtins.update vi.vname new_vi; + if Misc.is_library_loc vi.vdecl then + Misc.register_library_function new_vi; + if Builtins.mem vi.vname then Builtins.update vi.vname new_vi; l) else begin Misc.register_library_function vi;