Skip to content

Commit 4aacef1

Browse files
committed
Rule 8.13: Exclude results in ASM functions
1 parent cb07855 commit 4aacef1

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
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 variables in functions that use ASM commands
26+
not exists(AsmStmt a | a.getEnclosingFunction() = this.(LocalScopeVariable).getFunction()) and
2527
// Avoid elements in macro expansions, as they cannot be equated across copies
2628
not this.isInMacroExpansion() and
2729
exists(PointerOrArrayType type |

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,13 @@ char *f16(char *p1) { // NON_COMPLIANT
7575
int f17(char *p1) { // NON_COMPLIANT
7676
p1++;
7777
return 0;
78+
}
79+
80+
#include <stdint.h>
81+
82+
int16_t
83+
test_r(int16_t *value) { // COMPLIANT - ignored because of the use of ASM
84+
int16_t result;
85+
__asm__("movb %bh (%eax)");
86+
return result;
7887
}

0 commit comments

Comments
 (0)