identifier_length.cocci 467 B

123456789101112131415161718192021222324252627282930
  1. // Copyright: (C) 2019 Intel Corporation
  2. // SPDX-License-Identifier: Apache-2.0
  3. virtual report
  4. @r_idlen@
  5. type T;
  6. identifier I;
  7. constant C;
  8. position p;
  9. @@
  10. (
  11. T I@p (...);
  12. |
  13. I@p (...)
  14. |
  15. T I@p = C;
  16. |
  17. T I@p;
  18. )
  19. @script:python depends on report@
  20. id << r_idlen.I;
  21. pos << r_idlen.p;
  22. @@
  23. if (len(id) > 31):
  24. msg="WARNING: Violation to rule 5.1 or 5.2 (Identifiers shall be distinct) %s length %d > 31" % (id, len(id))
  25. coccilib.report.print_report(pos[0], msg)