Skip to content

Commit 7dab957

Browse files
committed
Rule 14.3: Correct bracketing
Exclusions would otherwise not be correctly applied.
1 parent 584d94c commit 7dab957

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

c/misra/src/rules/RULE-14-3/ControllingExprInvariant.ql

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,24 @@ where
3333
)
3434
) and
3535
message = "Controlling expression in if statement has invariant value."
36+
or
37+
exists(Loop loop |
38+
loop.getControllingExpr() = expr and
39+
(
40+
conditionAlwaysFalse(expr)
41+
or
42+
conditionAlwaysTrue(expr)
43+
)
44+
) and
45+
message = "Controlling expression in loop statement has invariant value."
46+
or
47+
exists(SwitchStmt switch |
48+
switch.getControllingExpr() = expr and
49+
(
50+
conditionAlwaysFalse(expr) or
51+
conditionAlwaysTrue(expr)
52+
)
53+
) and
54+
message = "Controlling expression in switch statement has invariant value."
3655
)
37-
or
38-
exists(Loop loop |
39-
loop.getControllingExpr() = expr and
40-
(
41-
conditionAlwaysFalse(expr)
42-
or
43-
conditionAlwaysTrue(expr)
44-
)
45-
) and
46-
message = "Controlling expression in loop statement has invariant value."
47-
or
48-
exists(SwitchStmt switch |
49-
switch.getControllingExpr() = expr and
50-
(
51-
conditionAlwaysFalse(expr) or
52-
conditionAlwaysTrue(expr)
53-
)
54-
) and
55-
message = "Controlling expression in switch statement has invariant value."
5656
select expr, message

0 commit comments

Comments
 (0)