Skip to content

Commit 2976916

Browse files
committed
Rule 8.13: Remove results in functions without bodies
1 parent f4f1160 commit 2976916

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

c/misra/src/rules/RULE-8-13/PointerShouldPointToConstTypeWhenPossible.ql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ import codingstandards.cpp.alertreporting.HoldsForAllCopies
2222

2323
class NonConstPointerVariableCandidate extends Variable {
2424
NonConstPointerVariableCandidate() {
25+
// Ignore parameters in functions without bodies
26+
(this instanceof Parameter implies exists(this.(Parameter).getFunction().getBlock())) and
2527
// Ignore variables in functions that use ASM commands
2628
not exists(AsmStmt a | a.getEnclosingFunction() = this.(LocalScopeVariable).getFunction()) and
2729
// Avoid elements in macro expansions, as they cannot be equated across copies

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,7 @@ void test_struct(struct S *s) { // COMPLIANT
9696

9797
void test_struct_2(struct S *s) { // NON_COMPLIANT - could be const
9898
s = 0;
99-
}
99+
}
100+
101+
void test_no_body(int *p); // COMPLIANT - no body, so cannot evaluate whether it
102+
// should be const

0 commit comments

Comments
 (0)