[Cocci] bug ? a newline after a cast to an unknown type prevents
from matching a function call
Julia Lawall
julia.lawall at lip6.fr
Sat Mar 10 07:21:16 CET 2012
On Fri, 9 Mar 2012, Derek M Jones wrote:
> Julia,
>
>> I have removed the test that the ) and the following identifier are on
>> the same line. Can anyone think of a case where one has
>>
>> (x)y
>>
>> or
>>
>> (x)n for an integer n
>>
>> where x is not a typedef?
>
> While C lets you write a[i] or i[a] it does not allow p(f)
> instead of f(p)
>
> How about an old-type function definition?
>
> typedef int y;
>
> f(x)
> y x;
> {
> ...
> }
>
> Very rare I suspect and not something to loose sleep over.
This may be what the test was intended to guard against.
>
> Of course there is the more obvious case of x being a macro name.
I don't see this one. You mean if x is a macro that expands to a type
name? As long as the whole thing remains a cast, I don't think it
matters.
thanks,
julia
>>
>> thanks,
>> julia
>>
>> On Mon, 5 Mar 2012, David Wagner wrote:
>>
>>> Hi,
>>>
>>> I may have stumbled upon a bug that prevents spatch from matching in a
>>> special case:
>>> The following SP is used:
>>>
>>> @match@
>>> identifier f;
>>> position p;
>>> @@
>>> f at p
>>> @script:python@
>>> f << match.f;
>>> p << match.p;
>>> @@
>>> print(f, p[0].line)
>>>
>>>
>>>
>>> It won't print anything when used on the following C file:
>>>
>>> void main() {
>>> unknown_tyepdef_1 td1;
>>> td1.attr = (unknown_typedef_2)
>>> td2.attr;
>>> foo();
>>> }
>>>
>>>
>>> however, on:
>>> void main() {
>>> unknown_tyepdef_1 td1;
>>> td1.attr = (unknown_typedef_2) td2.attr;
>>> foo();
>>> }
>>>
>>> it finds
>>> ('foo', '4')
>>> ('td1', '3')
>>> ('td2', '3')
>>>
>>> and on:
>>> void main() {
>>> unknown_typedef_1 td1;
>>> td1.attr = (int)
>>> td2.attr;
>>> foo();
>>> }
>>>
>>> it finds the same symbols (different lines, of course)
>>>
>>> If I define unknown_typedef_2 at the beginning of the file, it works
>>> as expected, though.
>>> Is it because coccinelle has no way to guess that it is a cast or is
>>> it a bug ?
>>>
>>> Regards,
>>> David.
>>> _______________________________________________
>>> Cocci mailing list
>>> Cocci at diku.dk
>>> http://lists.diku.dk/mailman/listinfo/cocci
>>> (Web access from inside DIKUs LAN only)
>>>
>> _______________________________________________
>> Cocci mailing list
>> Cocci at diku.dk
>> http://lists.diku.dk/mailman/listinfo/cocci
>> (Web access from inside DIKUs LAN only)
>>
>
> --
> Derek M. Jones tel: +44 (0) 1252 520 667
> Knowledge Software Ltd blog:shape-of-code.coding-guidelines.com
> Source code analysis http://www.knosof.co.uk
> _______________________________________________
> Cocci mailing list
> Cocci at diku.dk
> http://lists.diku.dk/mailman/listinfo/cocci
> (Web access from inside DIKUs LAN only)
>
More information about the Cocci
mailing list