Skip to content

Commit 6a1b346

Browse files
committed
files
1 parent 58383ae commit 6a1b346

File tree

8 files changed

+119
-8
lines changed

8 files changed

+119
-8
lines changed

.vscode/tasks.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@
223223
"Lambdas",
224224
"Language1",
225225
"Language2",
226+
"Language3",
226227
"Literals",
227228
"Loops",
228229
"Macros",
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
/**
22
* @id c/misra/language-extensions-should-not-be-used
33
* @name RULE-1-2: Language extensions should not be used
4-
* @description Language extensions can have inconsistent behavior and should not be used.
4+
* @description Language extensions are not portable to other compilers and should not be used.
55
* @kind problem
66
* @precision high
77
* @problem.severity error
88
* @tags external/misra/id/rule-1-2
99
* maintainability
1010
* readability
11-
* correctness
1211
* external/misra/obligation/advisory
1312
*/
14-
15-
import cpp
16-
import codingstandards.c.misra
17-
import codingstandards.c.Extensions
13+
import cpp
14+
import codingstandards.c.misra
15+
import codingstandards.c.Extensions
1816

1917
from CCompilerExtension e
2018
where
21-
not isExcluded(e, Language2Package::languageExtensionsShouldNotBeUsedQuery())
22-
select e, "Is a compiler extension and is not portable to other compilers."
19+
not isExcluded(e, Language3Package::languageExtensionsShouldNotBeUsedQuery())
20+
select e, "Is a compiler extension and is not portable to other compilers."
21+
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @id c/misra/occurrence-of-undefined-behavior
3+
* @name RULE-1-3: There shall be no occurrence of undefined or critical unspecified behavior
4+
* @description Relying on undefined or unspecified behavior can result in unreliable programs.
5+
* @kind problem
6+
* @precision high
7+
* @problem.severity error
8+
* @tags external/misra/id/rule-1-3
9+
* maintainability
10+
* readability
11+
* external/misra/obligation/required
12+
*/
13+
14+
import cpp
15+
import codingstandards.c.misra
16+
17+
from
18+
where
19+
not isExcluded(x, Language3Package::occurrenceOfUndefinedBehaviorQuery()) and
20+
select
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
No expected results have yet been specified
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rules/RULE-1-3/OccurrenceOfUndefinedBehavior.ql
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//** THIS FILE IS AUTOGENERATED, DO NOT MODIFY DIRECTLY. **/
2+
import cpp
3+
import RuleMetadata
4+
import codingstandards.cpp.exclusions.RuleMetadata
5+
6+
newtype Language3Query =
7+
TLanguageExtensionsShouldNotBeUsedQuery() or
8+
TOccurrenceOfUndefinedBehaviorQuery()
9+
10+
predicate isLanguage3QueryMetadata(Query query, string queryId, string ruleId) {
11+
query =
12+
// `Query` instance for the `languageExtensionsShouldNotBeUsed` query
13+
Language3Package::languageExtensionsShouldNotBeUsedQuery() and
14+
queryId =
15+
// `@id` for the `languageExtensionsShouldNotBeUsed` query
16+
"c/misra/language-extensions-should-not-be-used" and
17+
ruleId = "RULE-1-2"
18+
or
19+
query =
20+
// `Query` instance for the `occurrenceOfUndefinedBehavior` query
21+
Language3Package::occurrenceOfUndefinedBehaviorQuery() and
22+
queryId =
23+
// `@id` for the `occurrenceOfUndefinedBehavior` query
24+
"c/misra/occurrence-of-undefined-behavior" and
25+
ruleId = "RULE-1-3"
26+
}
27+
28+
module Language3Package {
29+
Query languageExtensionsShouldNotBeUsedQuery() {
30+
//autogenerate `Query` type
31+
result =
32+
// `Query` type for `languageExtensionsShouldNotBeUsed` query
33+
TQueryC(TLanguage3PackageQuery(TLanguageExtensionsShouldNotBeUsedQuery()))
34+
}
35+
36+
Query occurrenceOfUndefinedBehaviorQuery() {
37+
//autogenerate `Query` type
38+
result =
39+
// `Query` type for `occurrenceOfUndefinedBehavior` query
40+
TQueryC(TLanguage3PackageQuery(TOccurrenceOfUndefinedBehaviorQuery()))
41+
}
42+
}

cpp/common/src/codingstandards/cpp/exclusions/c/RuleMetadata.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import IO3
2222
import IO4
2323
import Language1
2424
import Language2
25+
import Language3
2526
import Misc
2627
import Pointers1
2728
import Pointers2
@@ -59,6 +60,7 @@ newtype TCQuery =
5960
TIO4PackageQuery(IO4Query q) or
6061
TLanguage1PackageQuery(Language1Query q) or
6162
TLanguage2PackageQuery(Language2Query q) or
63+
TLanguage3PackageQuery(Language3Query q) or
6264
TMiscPackageQuery(MiscQuery q) or
6365
TPointers1PackageQuery(Pointers1Query q) or
6466
TPointers2PackageQuery(Pointers2Query q) or
@@ -96,6 +98,7 @@ predicate isQueryMetadata(Query query, string queryId, string ruleId) {
9698
isIO4QueryMetadata(query, queryId, ruleId) or
9799
isLanguage1QueryMetadata(query, queryId, ruleId) or
98100
isLanguage2QueryMetadata(query, queryId, ruleId) or
101+
isLanguage3QueryMetadata(query, queryId, ruleId) or
99102
isMiscQueryMetadata(query, queryId, ruleId) or
100103
isPointers1QueryMetadata(query, queryId, ruleId) or
101104
isPointers2QueryMetadata(query, queryId, ruleId) or

rule_packages/c/Language3.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"MISRA-C-2012": {
3+
"RULE-1-2": {
4+
"properties": {
5+
"obligation": "advisory"
6+
},
7+
"queries": [
8+
{
9+
"description": "Language extensions are not portable to other compilers and should not be used.",
10+
"kind": "problem",
11+
"name": "Language extensions should not be used",
12+
"precision": "high",
13+
"severity": "error",
14+
"short_name": "LanguageExtensionsShouldNotBeUsed",
15+
"tags": [
16+
"maintainability",
17+
"readability"
18+
]
19+
}
20+
],
21+
"title": "Language extensions should not be used"
22+
},
23+
"RULE-1-3": {
24+
"properties": {
25+
"obligation": "required"
26+
},
27+
"queries": [
28+
{
29+
"description": "Relying on undefined or unspecified behavior can result in unreliable programs.",
30+
"kind": "problem",
31+
"name": "There shall be no occurrence of undefined or critical unspecified behavior",
32+
"precision": "high",
33+
"severity": "error",
34+
"short_name": "OccurrenceOfUndefinedBehavior",
35+
"tags": [
36+
"maintainability",
37+
"readability"
38+
]
39+
}
40+
],
41+
"title": "There shall be no occurrence of undefined or critical unspecified behavior"
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)