Skip to content
Snippets Groups Projects
Commit 475f9a90 authored by Allan Blanchard's avatar Allan Blanchard
Browse files

[E-ACSL] Compatibility with ghost qualifier

parent ba1415b2
No related branches found
No related tags found
No related merge requests found
...@@ -568,9 +568,13 @@ let inject_in_fundec main fundec = ...@@ -568,9 +568,13 @@ let inject_in_fundec main fundec =
let kf = try Globals.Functions.get vi with Not_found -> assert false in let kf = try Globals.Functions.get vi with Not_found -> assert false in
(* convert ghost variables *) (* convert ghost variables *)
vi.vghost <- false; vi.vghost <- false;
List.iter (fun vi -> vi.vghost <- false) fundec.slocals; let unghost_local vi =
vi.vtype <- Cil.typeRemoveAttributesDeep ["ghost"] vi.vtype ;
vi.vghost <- false
in
List.iter unghost_local fundec.slocals;
let unghost_formal vi = let unghost_formal vi =
vi.vghost <- false ; unghost_local vi ;
vi.vattr <- Cil.dropAttribute Cil.frama_c_ghost_formal vi.vattr vi.vattr <- Cil.dropAttribute Cil.frama_c_ghost_formal vi.vattr
in in
List.iter unghost_formal fundec.sformals; List.iter unghost_formal fundec.sformals;
...@@ -602,6 +606,7 @@ let unghost_vi vi = ...@@ -602,6 +606,7 @@ let unghost_vi vi =
(* do not convert extern ghost variables, because they can't be linked, (* do not convert extern ghost variables, because they can't be linked,
see bts #1392 *) see bts #1392 *)
if vi.vstorage <> Extern then vi.vghost <- false; if vi.vstorage <> Extern then vi.vghost <- false;
vi.vtype <- Cil.typeRemoveAttributesDeep ["ghost"] vi.vtype ;
match Cil.unrollType vi.vtype with match Cil.unrollType vi.vtype with
| TFun(res, Some l, va, attr) -> | TFun(res, Some l, va, attr) ->
(* unghostify function's parameters *) (* unghostify function's parameters *)
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
*/ */
/*@ ghost int G = 0; */ /*@ ghost int G = 0; */
/*@ ghost int *P; */ /*@ ghost int \ghost *P; */
// /*@ ghost int foo(int *x) { return *x + 1; } */ // /*@ ghost int foo(int *x) { return *x + 1; } */
int main(void) { int main(void) {
/*@ ghost P = &G; */ ; /*@ ghost P = &G; */ ;
/*@ ghost int *q = P; */ /*@ ghost int \ghost *q = P; */
/*@ ghost (*P)++; */ /*@ ghost (*P)++; */
/*@ assert *q == G; */ /*@ assert *q == G; */
// /*@ ghost G = foo(&G); */ // /*@ ghost G = foo(&G); */
......
/* run.config /* run.config
OPT: -load-script tests/declared/called_in_ghost.ml -print OPT: -kernel-warn-key ghost:bad-use=inactive -load-script tests/declared/called_in_ghost.ml -print
*/ */
// Note: we deactivate "ghost:bad-use" to check that printing goes right
/*@ assigns \nothing ; */ /*@ assigns \nothing ; */
void function(int e, ...); void function(int e, ...);
......
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