My thought was to find a field that is declared as const, then find a 
static initialization of that field, and then convert the initialized 
value to const.  So it would be something like:

@r@
identifier I1, I2, x;
@@

struct I1 {
  ...
  const struct I2 x;
  ...
};

@s@
identifier y,r.x;
identifier r.I1,y;
identifier E;
@@

struct I1 y = { ...,
  .x = E,
  ...
};

@@
identifier r.I2;
identifier s.E;
@@

+const
struct I2 E = { ... };

You would of course have to check that const is not already there as you 
have done in your previous rule.

I have not tested this at all.

julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to