123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- // Check violations for rule 14.4
- // https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_14_04.c
- //
- // Confidence: Moderate
- // Copyright: (C) 2021 Intel Corporation
- //
- // SPDX-License-Identifier: Apache-2.0
- virtual report
- @initialize:python@
- @@
- @rule1_base@
- identifier function, v;
- type T1, T2;
- parameter list[n] P1;
- parameter list[n1] P2;
- @@
- (
- T1 function(P1, T2 v, P2) {...}
- |
- T1 function(P1, T2 *v, P2) {...}
- )
- @ script:python @
- t << rule1_base.T2;
- v << rule1_base.v;
- @@
- if t == "bool":
- cocci.include_match(False)
- @rule1@
- identifier rule1_base.v;
- position p;
- @@
- (
- while (v@p) {...}
- |
- if (v@p) {...}
- )
- @ script:python @
- p << rule1.p;
- @@
- msg = "WARNING: Violation to rule 14.4 (Controlling expression shall have essentially Boolean type)"
- coccilib.report.print_report(p[0], msg)
- @rule2_base@
- identifier v;
- type T;
- @@
- T v;
- ...
- @ script:python @
- t << rule2_base.T;
- v << rule2_base.v;
- @@
- if t == "bool":
- cocci.include_match(False)
- @rule2@
- position p;
- identifier rule2_base.v;
- @@
- while (v@p) {...}
- @ script:python @
- p << rule2.p;
- @@
- msg = "WARNING: Violation to rule 14.4 (Controlling expression shall have essentially Boolean type)"
- coccilib.report.print_report(p[0], msg)
- @rule3@
- position p;
- constant c;
- @@
- (
- while (c@p) {...}
- |
- while (!c@p) {...}
- |
- if (c@p) {...}
- |
- if (!c@p) {...}
- )
- @ script:python @
- p << rule3.p;
- @@
- msg = "WARNING: Violation to rule 14.4 (Controlling expression shall have essentially Boolean type)"
- coccilib.report.print_report(p[0], msg)
|