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 e34fc46

Browse filesBrowse files
committed
import
1 parent aa040ad commit e34fc46
Copy full SHA for e34fc46

File tree

7 files changed

+79
-38
lines changed
Filter options

7 files changed

+79
-38
lines changed
+21Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* @id c/misra/language-not-encapsulated-and-isolated
3+
* @name DIR-4-3: Assembly language shall be encapsulated and isolated
4+
* @description Failing to encapsulate assembly language limits the portability, reliability, and
5+
* readability of programs.
6+
* @kind problem
7+
* @precision very-high
8+
* @problem.severity error
9+
* @tags external/misra/id/dir-4-3
10+
* maintainability
11+
* readability
12+
* external/misra/obligation/required
13+
*/
14+
15+
import cpp
16+
import codingstandards.c.misra
17+
18+
from
19+
where
20+
not isExcluded(x, Language1Package::languageNotEncapsulatedAndIsolatedQuery()) and
21+
select
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No expected results have yet been specified
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rules/DIR-4-3/LanguageNotEncapsulatedAndIsolated.ql

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

Copy file name to clipboard
+54Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#define N1 asm("HCF")
2+
#define N2 __asm__("HCF")
3+
4+
void f1(){
5+
int a;
6+
N1; // NON_COMPLIANT
7+
}
8+
9+
void f2(){
10+
int a;
11+
N2; // NON_COMPLIANT
12+
}
13+
14+
void f3(){
15+
N1;
16+
}
17+
18+
void f4(){
19+
N2;
20+
}
21+
22+
void f5(){
23+
__asm__("HCF");
24+
}
25+
26+
void f6(){
27+
asm("HCF");
28+
}
29+
30+
inline void f7(){
31+
int a;
32+
N1; // NON_COMPLIANT
33+
}
34+
35+
inline void f8(){
36+
int a;
37+
N2; // NON_COMPLIANT
38+
}
39+
40+
inline void f9(){
41+
N1;
42+
}
43+
44+
inline void f10(){
45+
N2;
46+
}
47+
48+
inline void f11(){
49+
__asm__("HCF");
50+
}
51+
52+
inline void f12(){
53+
asm("HCF");
54+
}

‎cpp/common/src/codingstandards/cpp/exclusions/c/Language1.qll

Copy file name to clipboardExpand all lines: cpp/common/src/codingstandards/cpp/exclusions/c/Language1.qll
+1-18Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ import cpp
33
import RuleMetadata
44
import codingstandards.cpp.exclusions.RuleMetadata
55

6-
newtype Language1Query =
7-
TLanguageNotEncapsulatedAndIsolatedQuery() or
8-
TLanguageExtensionsShouldNotBeUsedQuery()
6+
newtype Language1Query = TLanguageNotEncapsulatedAndIsolatedQuery()
97

108
predicate isLanguage1QueryMetadata(Query query, string queryId, string ruleId) {
119
query =
@@ -15,14 +13,6 @@ predicate isLanguage1QueryMetadata(Query query, string queryId, string ruleId) {
1513
// `@id` for the `languageNotEncapsulatedAndIsolated` query
1614
"c/misra/language-not-encapsulated-and-isolated" and
1715
ruleId = "DIR-4-3"
18-
or
19-
query =
20-
// `Query` instance for the `languageExtensionsShouldNotBeUsed` query
21-
Language1Package::languageExtensionsShouldNotBeUsedQuery() and
22-
queryId =
23-
// `@id` for the `languageExtensionsShouldNotBeUsed` query
24-
"c/misra/language-extensions-should-not-be-used" and
25-
ruleId = "RULE-1-2"
2616
}
2717

2818
module Language1Package {
@@ -32,11 +22,4 @@ module Language1Package {
3222
// `Query` type for `languageNotEncapsulatedAndIsolated` query
3323
TQueryC(TLanguage1PackageQuery(TLanguageNotEncapsulatedAndIsolatedQuery()))
3424
}
35-
36-
Query languageExtensionsShouldNotBeUsedQuery() {
37-
//autogenerate `Query` type
38-
result =
39-
// `Query` type for `languageExtensionsShouldNotBeUsed` query
40-
TQueryC(TLanguage1PackageQuery(TLanguageExtensionsShouldNotBeUsedQuery()))
41-
}
4225
}

‎rule_packages/c/Language1.json

Copy file name to clipboardExpand all lines: rule_packages/c/Language1.json
-19Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,6 @@
1919
}
2020
],
2121
"title": "Assembly language shall be encapsulated and isolated"
22-
},
23-
"RULE-1-2": {
24-
"properties": {
25-
"obligation": "advisory"
26-
},
27-
"queries": [
28-
{
29-
"description": "The use of language extensions may reduce the portability and reliability of programs.",
30-
"kind": "problem",
31-
"name": "Language extensions should not be used",
32-
"precision": "very-high",
33-
"severity": "error",
34-
"short_name": "LanguageExtensionsShouldNotBeUsed",
35-
"tags": [
36-
"maintainability"
37-
]
38-
}
39-
],
40-
"title": "Language extensions should not be used"
4122
}
4223
}
4324
}

‎rules.csv

Copy file name to clipboardExpand all lines: rules.csv
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ c,MISRA-C-2012,RULE-4-12,Yes,Required,,,Dynamic memory allocation shall not be u
617617
c,MISRA-C-2012,RULE-4-13,Yes,Advisory,,,Functions which are designed to provide operations on a resource should be called in an appropriate sequence,,Contracts,Hard,
618618
c,MISRA-C-2012,RULE-4-14,Yes,Required,,,The validity of values received from external sources shall be checked,,Contracts,Hard,
619619
c,MISRA-C-2012,RULE-1-1,Yes,Required,,,"The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation�s translation limits",,Language,Easy,
620-
c,MISRA-C-2012,RULE-1-2,Yes,Advisory,,,Language extensions should not be used,,Language1,Easy,
620+
c,MISRA-C-2012,RULE-1-2,Yes,Advisory,,,Language extensions should not be used,,Language,Easy,
621621
c,MISRA-C-2012,RULE-1-3,Yes,Required,,,There shall be no occurrence of undefined or critical unspecified behaviour,,Language,Hard,
622622
c,MISRA-C-2012,RULE-1-4,Yes,Required,,,Emergent language features shall not be used,,Language,Medium,
623623
c,MISRA-C-2012,RULE-2-1,Yes,Required,,,A project shall not contain unreachable code,M0-1-1,DeadCode,Import,

0 commit comments

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