File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change 1515
1616import cpp
1717import codingstandards.c.misra
18+ import codingstandards.c.misra.EssentialTypes
1819
19- from ControlFlowNode expr , string message
20+ from Expr expr , string message
2021where
2122 not isExcluded ( expr , Statements5Package:: controllingExprInvariantQuery ( ) ) and
2223 (
3536 exists ( Loop loop |
3637 loop .getControllingExpr ( ) = expr and
3738 (
38- conditionAlwaysFalse ( expr )
39+ conditionAlwaysFalse ( expr ) and
40+ not (
41+ getEssentialTypeCategory ( getEssentialType ( expr ) ) instanceof EssentiallyBooleanType and
42+ expr .getValue ( ) = "0"
43+ )
3944 or
4045 conditionAlwaysTrue ( expr ) and
4146 // Exception allows for infinite loops, but we only permit that for literals like `true`
Original file line number Diff line number Diff line change @@ -22,8 +22,13 @@ void f2() {
2222}
2323
2424void f3 () {
25- while (true) { // Permitted by exception
25+ while (true) { // COMPLIANT - permitted by exception 1
2626 }
2727 while (1 < 2 ) { // NON_COMPLIANT - likely an indication of a bug
2828 }
29+ }
30+
31+ void f4 () {
32+ do {
33+ } while (0u == 1u ); // COMPLIANT - by exception 2
2934}
You can’t perform that action at this time.
0 commit comments