Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 23b2007

Browse filesBrowse files
committed
implementation
1 parent e34fc46 commit 23b2007
Copy full SHA for 23b2007

File tree

3 files changed

+71
-34
lines changed
Filter options

3 files changed

+71
-34
lines changed

‎c/misra/src/rules/DIR-4-3/LanguageNotEncapsulatedAndIsolated.ql

Copy file name to clipboardExpand all lines: c/misra/src/rules/DIR-4-3/LanguageNotEncapsulatedAndIsolated.ql
+10-3Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,14 @@
1515
import cpp
1616
import codingstandards.c.misra
1717

18-
from
18+
from AsmStmt asm
1919
where
20-
not isExcluded(x, Language1Package::languageNotEncapsulatedAndIsolatedQuery()) and
21-
select
20+
not isExcluded(asm, Language1Package::languageNotEncapsulatedAndIsolatedQuery()) and
21+
not exists(asm.getEnclosingFunction())
22+
or
23+
// in concept statements within the body constitute intermingling assembly,
24+
// rather than expressions and are more general.
25+
exists(Stmt sp | sp = asm.getEnclosingFunction().getEntryPoint().getASuccessor*() |
26+
not sp instanceof AsmStmt and not sp instanceof ReturnStmt and not sp instanceof BlockStmt
27+
)
28+
select asm, "Usage of non-isolated and non-encapsulated assembly language."
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
No expected results have yet been specified
1+
| test.c:6:3:6:5 | asm statement | Usage of non-isolated and non-encapsulated assembly language. |
2+
| test.c:11:3:11:5 | asm statement | Usage of non-isolated and non-encapsulated assembly language. |
3+
| test.c:32:3:32:5 | asm statement | Usage of non-isolated and non-encapsulated assembly language. |
4+
| test.c:37:3:37:5 | asm statement | Usage of non-isolated and non-encapsulated assembly language. |
5+
| test.c:58:3:58:5 | asm statement | Usage of non-isolated and non-encapsulated assembly language. |

‎c/misra/test/rules/DIR-4-3/test.c

Copy file name to clipboard
+56-30Lines changed: 56 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,80 @@
1-
#define N1 asm("HCF")
2-
#define N2 __asm__("HCF")
1+
#define N1 asm("HCF")
2+
#define N2 __asm__("HCF")
33

4-
void f1(){
5-
int a;
6-
N1; // NON_COMPLIANT
4+
void f1() {
5+
int a;
6+
N1; // NON_COMPLIANT
77
}
88

9-
void f2(){
10-
int a;
11-
N2; // NON_COMPLIANT
9+
void f2() {
10+
int a;
11+
N2; // NON_COMPLIANT
1212
}
1313

14-
void f3(){
15-
N1;
14+
void f3() {
15+
N1; // COMPLIANT
1616
}
1717

18-
void f4(){
19-
N2;
18+
void f4() {
19+
N2; // COMPLIANT
2020
}
2121

22-
void f5(){
23-
__asm__("HCF");
22+
void f5() {
23+
__asm__("HCF"); // COMPLIANT
2424
}
2525

26-
void f6(){
27-
asm("HCF");
26+
void f6() {
27+
asm("HCF"); // COMPLIANT
2828
}
2929

30-
inline void f7(){
31-
int a;
32-
N1; // NON_COMPLIANT
30+
inline void f7() {
31+
int a;
32+
N1; // NON_COMPLIANT
3333
}
3434

35-
inline void f8(){
36-
int a;
37-
N2; // NON_COMPLIANT
35+
inline void f8() {
36+
int a;
37+
N2; // NON_COMPLIANT
3838
}
3939

40-
inline void f9(){
41-
N1;
40+
inline void f9() {
41+
N1; // COMPLIANT
4242
}
4343

44-
inline void f10(){
45-
N2;
44+
inline void f10() {
45+
N2; // COMPLIANT
4646
}
4747

48-
inline void f11(){
49-
__asm__("HCF");
48+
inline void f11() {
49+
__asm__("HCF"); // COMPLIANT
5050
}
5151

52-
inline void f12(){
53-
asm("HCF");
52+
inline void f12() {
53+
asm("HCF"); // COMPLIANT
54+
}
55+
56+
inline int f13() {
57+
int a;
58+
N2; // NON_COMPLIANT
59+
return 0;
60+
}
61+
62+
inline int f14() {
63+
N1; // COMPLIANT
64+
return 0;
65+
}
66+
67+
inline int f15() {
68+
N2; // COMPLIANT
69+
return 0;
70+
}
71+
72+
inline int f16() {
73+
__asm__("HCF"); // COMPLIANT
74+
return 0;
75+
}
76+
77+
inline int f17() {
78+
asm("HCF"); // COMPLIANT
79+
return 0;
5480
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.