Skip to content

Commit ccb20d5

Browse files
committed
Rule 8.13: Support crement operatios.
1 parent 808554e commit ccb20d5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

c/misra/test/rules/RULE-8-13/test.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,8 @@ void test_struct_2(struct S *s) { // NON_COMPLIANT - could be const
105105
}
106106

107107
void test_no_body(int *p); // COMPLIANT - no body, so cannot evaluate whether it
108-
// should be const
108+
// should be const
109+
110+
void increment(int *p) { // COMPLIANT
111+
*p++ = 1;
112+
}

cpp/common/src/codingstandards/cpp/SideEffect.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ Expr getAnEffect(Expr base) {
190190
or
191191
exists(PointerDereferenceExpr e | e.getOperand() = base | result = getAnEffect(e))
192192
or
193+
exists(CrementOperation c | c.getOperand() = base | result = getAnEffect(c))
194+
or
193195
// local alias analysis, assume alias when data flows to derived type (pointer/reference)
194196
// auto ptr = &base;
195197
exists(VariableAccess va, AddressOfExpr addressOf |

0 commit comments

Comments
 (0)