Skip to content
Snippets Groups Projects
Commit ce51baf0 authored by Virgile Prevosto's avatar Virgile Prevosto
Browse files

Merge branch 'fix/cil/rmtmps-static' into 'master'

[Cil] fix the dangling reference to removed unused static variables

Closes #624

See merge request frama-c/frama-c!2242
parents 41cf758b 2c4c1a03
No related branches found
No related tags found
No related merge requests found
...@@ -821,7 +821,8 @@ let removeUnmarked isRoot ast reachable_tbl = ...@@ -821,7 +821,8 @@ let removeUnmarked isRoot ast reachable_tbl =
Keep variables that were already present in the code. Keep variables that were already present in the code.
*) *)
let filterLocal local = let filterLocal local =
if local.vtemp && not (is_reachable reachable_tbl (Var local)) then if (local.vtemp || local.vstorage = Static) &&
not (is_reachable reachable_tbl (Var local)) then
begin begin
(* along the way, record the interesting locals that were removed *) (* along the way, record the interesting locals that were removed *)
let name = local.vname in let name = local.vname in
...@@ -836,6 +837,7 @@ let removeUnmarked isRoot ast reachable_tbl = ...@@ -836,6 +837,7 @@ let removeUnmarked isRoot ast reachable_tbl =
inherit Cil.nopCilVisitor inherit Cil.nopCilVisitor
method! vblock b = method! vblock b =
b.blocals <- List.filter filterLocal b.blocals; b.blocals <- List.filter filterLocal b.blocals;
b.bstatics <- List.filter filterLocal b.bstatics;
DoChildren DoChildren
end end
in in
......
[kernel] Parsing tests/syntax/rmtmps_static.i (no preprocessing)
/* Generated by Frama-C */
int f(void);
int f(void)
{
int __retres;
__retres = 0;
return __retres;
}
int f() {
static int x = 0;
return 0;
}
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