Hello,

take this not beautiful nor pretty but valid and (sadly) common C code:
typedef struct IFace IFace;
typedef struct Object Object;

int foo(IFace *iface)
{
    Object *This = (Object *)iface;
    return 2;
}

int bar(IFace *iface)
{
    Object *This = (struct Object *)iface;
    return 1;
}

It would be nice if following SmPL would work:
@@
typedef IFace;
typedef Object;
IFace *iface;
@@
(
- (Object *)(iface)
+ impl_from_IFace(iface)
|
- (struct Object *)(iface)
+ impl_from_IFace(iface)
)

Fatal error: exception Failure("minus: parse error:
 = File "struct.cocci", line 10, column 10,  charpos = 110
    around = 'Object', whole content = - (struct Object *)(iface)

I helped myself out by splitting up the rules and moving the "struct
Object" rules before the "typedef Object;" but it gets complicated
pretty fast. And looking up the "typedef struct X X" in a nested header
file is unpractical due to the massive performance hit of handling
recursive includes. Thus support for the "tags" name space would be a
nice thing to have in coccinelle.


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

Reply via email to