> 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.

Can this result be expected when your source code transformation
approach is just very generic?


> 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;
>             ^~~~~


Would you like to add any SmPL filter specifications for such qualifiers?


> I even tried prepending an alternation with "const T good;" but the cast
> still gets removed.

* How do you think about to check the function parameter properties
  in more detail?

* Under which circumstances would you try to cast constness away?

* Would you like to distinguish the involved data types any more?

Regards,
Markus
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to