File tree Expand file tree Collapse file tree 3 files changed +71
-34
lines changed Expand file tree Collapse file tree 3 files changed +71
-34
lines changed Original file line number Diff line number Diff line change 1515import cpp
1616import codingstandards.c.misra
1717
18- from
18+ from AsmStmt asm
1919where
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."
Original file line number Diff line number Diff line change 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. |
Original file line number Diff line number Diff line change 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}
You can’t perform that action at this time.
0 commit comments