Skip to content
Snippets Groups Projects
Commit dd7e4c6b authored by Thibault Martin's avatar Thibault Martin Committed by Virgile Prevosto
Browse files

Add is_frama_c_builtin: checks FC attr and start_with_Frama_C

parent 81c535ac
No related branches found
No related tags found
No related merge requests found
...@@ -172,22 +172,18 @@ class visitor = object(self) ...@@ -172,22 +172,18 @@ class visitor = object(self)
if not (isGhostType (typeOfLval lv)) then if not (isGhostType (typeOfLval lv)) then
Error.assigns_non_ghost_lvalue ~current:true lv Error.assigns_non_ghost_lvalue ~current:true lv
in in
let is_builtin vi =
Ast_info.start_with_frama_c_builtin vi.vname ||
Cil_builtins.has_fc_builtin_attr vi
in
let failed = match i with let failed = match i with
| Call(_, fexp, _, _) -> | Call(_, fexp, _, _) ->
begin match Kernel_function.(Option.map get_vi @@ get_called fexp) with begin match Kernel_function.(Option.map get_vi @@ get_called fexp) with
| Some fct | Some fct
when not (is_builtin fct) && not fct.vghost -> when not (Ast_info.is_frama_c_builtin fct) && not fct.vghost ->
Error.non_ghost_function_call_in_ghost ~current:true () ; true Error.non_ghost_function_call_in_ghost ~current:true () ; true
| None -> | None ->
Error.function_pointer_call ~current:true () ; true Error.function_pointer_call ~current:true () ; true
| _ -> false | _ -> false
end end
| Local_init(_, ConsInit(fct, _, _), _) | Local_init(_, ConsInit(fct, _, _), _)
when not (is_builtin fct) && not fct.vghost -> when not (Ast_info.is_frama_c_builtin fct) && not fct.vghost ->
Error.non_ghost_function_call_in_ghost ~current:true () ; true Error.non_ghost_function_call_in_ghost ~current:true () ; true
| _ -> false | _ -> false
in in
...@@ -200,10 +196,10 @@ class visitor = object(self) ...@@ -200,10 +196,10 @@ class visitor = object(self)
| Call(_, fexp, _, _) -> | Call(_, fexp, _, _) ->
let vi = let vi =
Kernel_function.(get_vi @@ Option.get @@ get_called fexp) in Kernel_function.(get_vi @@ Option.get @@ get_called fexp) in
if not (is_builtin vi) then if not (Ast_info.is_frama_c_builtin vi) then
error_if_incompatible lv (getReturnType (typeOf fexp)) fexp error_if_incompatible lv (getReturnType (typeOf fexp)) fexp
| Local_init(_, ConsInit(fct, _, _), _) -> | Local_init(_, ConsInit(fct, _, _), _) ->
if not (is_builtin fct) then if not (Ast_info.is_frama_c_builtin fct) then
error_if_incompatible lv (getReturnType fct.vtype) (evar fct) error_if_incompatible lv (getReturnType fct.vtype) (evar fct)
| _ -> () | _ -> ()
end end
......
...@@ -491,6 +491,9 @@ let start_with_frama_c_builtin n = ...@@ -491,6 +491,9 @@ let start_with_frama_c_builtin n =
is_domain_show_each_builtin n || is_domain_show_each_builtin n ||
is_dump_file_builtin n) is_dump_file_builtin n)
let is_frama_c_builtin v =
Cil_builtins.has_fc_builtin_attr v || start_with_frama_c_builtin v.vname
let () = Cil_builtins.add_special_builtin_family start_with_frama_c_builtin let () = Cil_builtins.add_special_builtin_family start_with_frama_c_builtin
(* (*
......
...@@ -275,6 +275,12 @@ val start_with_frama_c_builtin: string -> bool ...@@ -275,6 +275,12 @@ val start_with_frama_c_builtin: string -> bool
@since Frama-C+dev @since Frama-C+dev
*) *)
val is_frama_c_builtin: varinfo -> bool
(** @return true if {!start_with_frama_c_builtin} or
{!Cil_builtins.has_fc_builtin_attr} are true.
@before Frama-C+dev Behave like {!start_with_frama_c_builtin}.
*)
(* (*
Local Variables: Local Variables:
compile-command: "make -C ../../.." compile-command: "make -C ../../.."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment