Skip to content

Commit 808554e

Browse files
committed
Rule 8.13: Expand ASM test
1 parent 2976916 commit 808554e

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ class NonConstPointerVariableCandidate extends Variable {
2525
// Ignore parameters in functions without bodies
2626
(this instanceof Parameter implies exists(this.(Parameter).getFunction().getBlock())) and
2727
// Ignore variables in functions that use ASM commands
28-
not exists(AsmStmt a | a.getEnclosingFunction() = this.(LocalScopeVariable).getFunction()) and
28+
not exists(AsmStmt a |
29+
a.getEnclosingFunction() = this.(LocalScopeVariable).getFunction()
30+
or
31+
// In a type declared locally
32+
this.(Field).getDeclaringType+().getEnclosingFunction() = a.getEnclosingFunction()
33+
) and
2934
// Avoid elements in macro expansions, as they cannot be equated across copies
3035
not this.isInMacroExpansion() and
3136
exists(PointerOrArrayType type |

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
| test.c:66:23:66:24 | p1 | $@ points to a non-const-qualified type. | test.c:66:23:66:24 | p1 | p1 |
1313
| test.c:71:17:71:18 | p1 | $@ points to a non-const-qualified type. | test.c:71:17:71:18 | p1 | p1 |
1414
| test.c:75:15:75:16 | p1 | $@ points to a non-const-qualified type. | test.c:75:15:75:16 | p1 | p1 |
15-
| test.c:97:30:97:30 | s | $@ points to a non-const-qualified type. | test.c:97:30:97:30 | s | s |
15+
| test.c:103:30:103:30 | s | $@ points to a non-const-qualified type. | test.c:103:30:103:30 | s | s |

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ int f17(char *p1) { // NON_COMPLIANT
8282
int16_t
8383
test_r(int16_t *value) { // COMPLIANT - ignored because of the use of ASM
8484
int16_t result;
85+
struct S {
86+
int *x; // COMPLIANT - ignored because of the use of ASM
87+
struct S2 {
88+
int *y; // COMPLIANT - ignored because of the use of ASM
89+
} s2;
90+
};
8591
__asm__("movb %bh (%eax)");
8692
return result;
8793
}

0 commit comments

Comments
 (0)