---

** [bugs:#142] Problem with AddrOfLabel and CopyFunction**

**Status:** open
**Created:** Tue Jan 14, 2014 08:41 PM UTC by az bro
**Last Updated:** Tue Jan 14, 2014 08:41 PM UTC
**Owner:** nobody

CopyFunction doesn't update AddrOfLabel which also 
has a ref to the statement containing the label, 
just like Goto does. 

This is the output I get from the code below:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
digraph CFG_f_new {
0 [label="0: instr"]
        0 -> 1
1 [label="1: goto"]
        1 -> 3
2 [label="2: instr"]
        2 -> 3
3 [label="3: instr"]
        3 -> 4
4 [label="4: return"]

}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
digraph CFG_f_new {
6 [label="6: instr"]
        6 -> 7
7 [label="7: goto"]
        7 -> 3
8 [label="8: instr"]
        8 -> 9
9 [label="9: instr"]
        9 -> 10
10 [label="10: return"]

}


====================================================================================

open List

let () = begin
     Cil.useComputedGoto := true;
     Cil.insertImplicitCasts := true;
     Cil.print_CIL_Input := false;
     Cil.lineDirectiveStyle := None;
end

let feature : Cil.featureDescr = {
   Cil.fd_name = "CFGTest";

   Cil.fd_enabled = ref false;
   
   Cil.fd_description = "";
   
   Cil.fd_extraopt = [ ];

   Cil.fd_doit = (fun f ->
       let funG = List.find (fun g ->
          match g with
             | GFun(func,_) when func.svar.vname = "f" -> true
             | _                                       -> false
          ) f.globals in
       let func = match funG with
           | GFun(func,_) -> func
           | _            -> raise (Failure("GFun"))
       in (
          ignore(Cfg.clearCFGinfo func);
          ignore(Cfg.cfgFun func);

          let newFunc = Cil.copyFunction func "f_new" in (
             
print_endline("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
             Cfg.printCfgChannel stdout newFunc;
             
print_endline("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");

             ignore(Cfg.clearCFGinfo newFunc);
             ignore(Cfg.cfgFun newFunc);

             
print_endline("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
             Cfg.printCfgChannel stdout newFunc;
             
print_endline("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%");
          )
      )
   );
   
   Cil.fd_post_check = true
} 


====================================================================================

#include<stdio.h>

int f() {
 void* lll = &&lab1;
 goto *lll;
 printf("xxx\n");
 lab1:
 printf("yyy\n");
 return 0;
}

int main () {
 int v;
 v = f();
}

====================================================================================



---

Sent from sourceforge.net because cil-users@lists.sourceforge.net is subscribed 
to https://sourceforge.net/p/cil/bugs/

To unsubscribe from further messages, a project admin can change settings at 
https://sourceforge.net/p/cil/admin/bugs/options.  Or, if this is a mailing 
list, you can unsubscribe from the mailing list.
------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
CIL-users mailing list
CIL-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cil-users

Reply via email to