On Thu, 14 Feb 2019, Michael Stefaniuc wrote:
> Hello,
>
> I have this trivial script to remove useless casts to self:
> @ disable drop_cast @
> type T;
> T E;
> @@
> - (T)
> E
>
> It works but I'm hitting false positives when the code casts away
> qualifiers for field types. Please see the attached test case:
> - Good: Cast is kept in foo()
> - Bad: Cast is dropped in baz()
>
> Applying the generated diff will lead to a gcc warning:
> $ gcc -c qualifier.c
> qualifier.c: In function ‘baz’:
> qualifier.c:12:12: warning: return discards ‘const’ qualifier from
> pointer target type [-Wdiscarded-qualifiers]
> return &b->i;
> ^~~~~
>
> I tried disabling the optional_qualifier iso but that has no effect:
> - Not needed for the foo() case
> - No effect for the baz() case
>
> I even tried prepending an alternation with "const T good;" but the cast
> still gets removed.
The const is now propagated to the fields. Let me know if there are
further problems.
julia
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci