Skip to content

Commit d8cd0bf

Browse files
committed
Implement RULE-12-5
1 parent 405f28b commit d8cd0bf

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

c/misra/src/rules/RULE-12-5/SizeofOperatorUsedOnArrayTypeParam.ql

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
import cpp
1414
import codingstandards.c.misra
1515

16-
from
16+
from SizeofExprOperator sizeof
1717
where
18-
not isExcluded(x, TypesPackage::sizeofOperatorUsedOnArrayTypeParamQuery()) and
19-
select
18+
not isExcluded(sizeof, TypesPackage::sizeofOperatorUsedOnArrayTypeParamQuery()) and
19+
exists(Parameter param |
20+
sizeof.getExprOperand().(VariableAccess).getTarget() = param and
21+
param.getType() instanceof ArrayType
22+
)
23+
select sizeof,
24+
"The sizeof operator is called on an array-type parameter " + sizeof.getExprOperand() + "."
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
No expected results have yet been specified
1+
| test.c:6:12:6:23 | sizeof(<expr>) | The sizeof operator is called on an array-type parameter nums. |
2+
| test.c:13:12:13:25 | sizeof(<expr>) | The sizeof operator is called on an array-type parameter string. |

0 commit comments

Comments
 (0)