Skip to content

Commit 06866d8

Browse files
committed
Rule 10.1: Handle ~, improve output
- Add support for the ~ operator. - Report the operand, not the operator - Fix typo in one message
1 parent d22328b commit 06866d8

File tree

2 files changed

+195
-190
lines changed

2 files changed

+195
-190
lines changed

c/misra/src/rules/RULE-10-1/OperandsOfAnInappropriateEssentialType.ql

+4-3
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ predicate isInappropriateEssentialType(
178178
child =
179179
[
180180
operator.(BinaryBitwiseOperation).getAnOperand(),
181-
operator.(Bitwise::AssignBitwiseOperation).getAnOperand()
181+
operator.(Bitwise::AssignBitwiseOperation).getAnOperand(),
182+
operator.(ComplementExpr).getAnOperand()
182183
] and
183184
not operator instanceof LShiftExpr and
184185
not operator instanceof RShiftExpr and
@@ -240,7 +241,7 @@ string getRationaleMessage(int rationaleId, EssentialTypeCategory etc) {
240241
result = "Bitwise operator applied to operand of " + etc + " and not essentially unsigned."
241242
or
242243
rationaleId = 7 and
243-
result = "Right hand operatand of shift operator is " + etc + " and not not essentially unsigned."
244+
result = "Right hand operand of shift operator is " + etc + " and not not essentially unsigned."
244245
or
245246
rationaleId = 8 and
246247
result =
@@ -251,4 +252,4 @@ from Expr operator, Expr child, int rationaleId, EssentialTypeCategory etc
251252
where
252253
not isExcluded(operator, EssentialTypesPackage::operandsOfAnInappropriateEssentialTypeQuery()) and
253254
isInappropriateEssentialType(operator, child, etc, rationaleId)
254-
select operator, getRationaleMessage(rationaleId, etc)
255+
select child, getRationaleMessage(rationaleId, etc)

0 commit comments

Comments
 (0)