Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit0c7b503

Browse files
save work
1 parentce5b364 commit0c7b503

File tree

19 files changed

+298
-66
lines changed

19 files changed

+298
-66
lines changed

‎amendments.csv‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ c,MISRA-C-2012,Corrigendum2,RULE-1-4,Yes,Replace,No,Easy
2828
c,MISRA-C-2012,Corrigendum2,RULE-9-1,Yes,Refine,No,Easy
2929
c,MISRA-C-2012,Corrigendum2,RULE-9-2,Yes,Refine,No,Import
3030
c,MISRA-C-2012,Corrigendum2,DIR-4-10,Yes,Clarification,No,Import
31-
c,MISRA-C-2012,Corrigendum2,RULE-7-4,Yes,Refine,No,Easy
31+
c,MISRA-C-2012,Corrigendum2,RULE-7-4,Yes,Refine,Yes,Easy
3232
c,MISRA-C-2012,Corrigendum2,RULE-8-2,Yes,Clarification,No,Import
33-
c,MISRA-C-2012,Corrigendum2,RULE-8-3,Yes,Refine,No,Easy
33+
c,MISRA-C-2012,Corrigendum2,RULE-8-3,Yes,Refine,Yes,Easy
3434
c,MISRA-C-2012,Corrigendum2,RULE-8-7,Yes,Clarification,No,Import
35-
c,MISRA-C-2012,Corrigendum2,RULE-10-2,Yes,Refine,No,Easy
35+
c,MISRA-C-2012,Corrigendum2,RULE-10-2,Yes,Refine,Yes,Easy
3636
c,MISRA-C-2012,Corrigendum2,RULE-10-3,Yes,Clarification,No,Import
3737
c,MISRA-C-2012,Corrigendum2,RULE-11-3,Yes,Clarification,No,Import
3838
c,MISRA-C-2012,Corrigendum2,RULE-11-6,Yes,Clarification,No,Import
3939
c,MISRA-C-2012,Corrigendum2,RULE-13-2,Yes,Clarification,No,Import
4040
c,MISRA-C-2012,Corrigendum2,RULE-13-6,Yes,Clarification,No,Import
41-
c,MISRA-C-2012,Corrigendum2,RULE-14-3,Yes,Refine,No,Easy
41+
c,MISRA-C-2012,Corrigendum2,RULE-14-3,Yes,Refine,Yes,Easy
4242
c,MISRA-C-2012,Corrigendum2,RULE-15-7,Yes,Clarification,No,Import
4343
c,MISRA-C-2012,Corrigendum2,RULE-17-4,Yes,Clarification,No,Import
4444
c,MISRA-C-2012,Corrigendum2,RULE-17-5,Yes,Clarification,No,Import
45-
c,MISRA-C-2012,Corrigendum2,RULE-18-1,Yes,Refine,No,Easy
45+
c,MISRA-C-2012,Corrigendum2,RULE-18-1,Yes,Refine,Yes,Easy
4646
c,MISRA-C-2012,Corrigendum2,RULE-20-14,No,Clarification,No,Import
4747
c,MISRA-C-2012,Corrigendum2,RULE-21-19,Yes,Clarification,No,Import
48-
c,MISRA-C-2012,Corrigendum2,RULE-21-20,Yes,Refine,No,Easy
48+
c,MISRA-C-2012,Corrigendum2,RULE-21-20,Yes,Refine,Yes,Easy
4949
c,MISRA-C-2012,Corrigendum2,RULE-22-9,Yes,Clarification,No,Import

‎c/misra/src/codingstandards/c/misra/EssentialTypes.qll‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,15 @@ class EssentialBinaryArithmeticExpr extends EssentialExpr, BinaryArithmeticOpera
297297
exists(
298298
TypeleftEssentialType,TyperightEssentialType,
299299
EssentialTypeCategoryleftEssentialTypeCategory,
300-
EssentialTypeCategoryrightEssentialTypeCategory
300+
EssentialTypeCategoryrightEssentialTypeCategory,
301+
intintTypeSize
301302
|
302303
leftEssentialType=getEssentialType(getLeftOperand())and
303304
rightEssentialType=getEssentialType(getRightOperand())and
304305
leftEssentialTypeCategory=getEssentialTypeCategory(leftEssentialType)and
305-
rightEssentialTypeCategory=getEssentialTypeCategory(rightEssentialType)
306+
rightEssentialTypeCategory=getEssentialTypeCategory(rightEssentialType)and
307+
// For rules around addition/subtraction with char types:
308+
intTypeSize=any(IntTypei|i.isSigned()).getSize()
306309
|
307310
if
308311
leftEssentialTypeCategory=EssentiallySignedType()and
@@ -338,15 +341,18 @@ class EssentialBinaryArithmeticExpr extends EssentialExpr, BinaryArithmeticOpera
338341
(
339342
leftEssentialTypeCategory=
340343
[EssentiallySignedType(),EssentiallyUnsignedType().(TEssentialTypeCategory)]
344+
andleftEssentialType.getSize()<=intTypeSize
341345
or
342346
rightEssentialTypeCategory=
343347
[EssentiallySignedType(),EssentiallyUnsignedType().(TEssentialTypeCategory)]
348+
andrightEssentialType.getSize()<=intTypeSize
344349
)
345350
or
346351
thisinstanceofSubExprand
347352
leftEssentialTypeCategory=EssentiallyCharacterType()and
348353
rightEssentialTypeCategory=
349354
[EssentiallySignedType(),EssentiallyUnsignedType().(TEssentialTypeCategory)]
355+
andrightEssentialType.getSize()<=intTypeSize
350356
thenresultinstanceofPlainCharType
351357
elseresult=this.getStandardType()
352358
)

‎c/misra/src/rules/RULE-10-2/AdditionSubtractionOnEssentiallyCharType.ql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ where
3232
// But the overall essential type is not essentially character type
3333
getEssentialTypeCategory(getEssentialType(addOrSub))=EssentiallyCharacterType()
3434
or
35-
// Or this is asubtration of one character with another, which is permitted, but produces an integral type
35+
// Or this is asubtraction of one character with another, which is permitted, but produces an integral type
3636
getEssentialTypeCategory(getEssentialType(addOrSub.getLeftOperand()))=
3737
EssentiallyCharacterType()and
3838
getEssentialTypeCategory(getEssentialType(addOrSub.getRightOperand()))=
Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1-
| test.c:15:3:15:11 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
2-
| test.c:16:3:16:9 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
3-
| test.c:17:3:17:9 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
4-
| test.c:18:3:18:9 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
5-
| test.c:19:3:19:9 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
6-
| test.c:20:3:20:10 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
7-
| test.c:21:3:21:10 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
8-
| test.c:27:3:27:9 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
9-
| test.c:28:3:28:9 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
10-
| test.c:29:3:29:9 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
11-
| test.c:30:3:30:9 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
12-
| test.c:31:3:31:9 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
13-
| test.c:32:3:32:9 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
14-
| test.c:33:3:33:10 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
15-
| test.c:34:3:34:10 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
1+
| test.c:19:3:19:11 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
2+
| test.c:20:3:20:9 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
3+
| test.c:21:3:21:9 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
4+
| test.c:22:3:22:9 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
5+
| test.c:23:3:23:9 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
6+
| test.c:24:3:24:10 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
7+
| test.c:25:3:25:10 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
8+
| test.c:28:3:28:9 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
9+
| test.c:29:3:29:10 | ... + ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
10+
| test.c:35:3:35:9 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
11+
| test.c:36:3:36:9 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
12+
| test.c:37:3:37:9 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
13+
| test.c:38:3:38:9 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
14+
| test.c:39:3:39:9 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
15+
| test.c:40:3:40:9 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
16+
| test.c:41:3:41:10 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
17+
| test.c:42:3:42:10 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
18+
| test.c:45:3:45:9 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |
19+
| test.c:46:3:46:10 | ... - ... | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations |

‎c/misra/test/rules/RULE-10-2/test.c‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ void testRules() {
55
enumE1 {A,B,C }e1=A;
66
signedinti=100;
77
unsignedintu=100;
8+
signed shorts=100;
9+
unsigned shortus=100;
10+
signed longl=100L;
11+
unsigned longul=100UL;
812
floatf=10.0f;
913

1014
// Addition cases
@@ -19,8 +23,12 @@ void testRules() {
1923
b+'a';// NON_COMPLIANT
2024
'a'+e1;// NON_COMPLIANT
2125
e1+'a';// NON_COMPLIANT
26+
'a'+s;// COMPLIANT
27+
'a'+us;// COMPLIANT
28+
'a'+l;// NON_COMPLIANT
29+
'a'+ul;// NON_COMPLIANT
2230

23-
//Subtration cases
31+
//Subtraction cases
2432
'a'-i;// COMPLIANT
2533
'a'-u;// COMPLIANT
2634
'a'-'a';// COMPLIANT
@@ -32,4 +40,8 @@ void testRules() {
3240
'a'-b;// NON_COMPLIANT
3341
e1-'a';// NON_COMPLIANT
3442
'a'-e1;// NON_COMPLIANT
43+
'a'-s;// COMPLIANT
44+
'a'-us;// COMPLIANT
45+
'a'-l;// NON_COMPLIANT
46+
'a'-ul;// NON_COMPLIANT
3547
}

‎c/misra/test/rules/RULE-14-3/ControllingExprInvariant.expected‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
| test.c:27:10:27:14 | ... < ... | Controlling expression in loop statement has an invariant value. |
66
| test.c:37:3:37:6 | 1 | Controlling expression in conditional statement has an invariant value. |
77
| test.c:38:3:38:3 | 1 | Controlling expression in conditional statement has an invariant value. |
8+
| test.c:45:10:45:26 | ... && ... | Controlling expression in loop statement has an invariant value. |

‎c/misra/test/rules/RULE-14-3/test.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,11 @@ void f5(bool b1) {
3737
true ?1 :2;// NON_COMPLIANT
3838
1 ?1 :2;// NON_COMPLIANT
3939
b1 ?1 :2;// COMPLIANT
40+
}
41+
42+
voidf6(intp1) {
43+
while (p1<10&&p1>12) {// NON_COMPLIANT[FALSE_NEGATIVE]
44+
}
45+
while (1==0&&p1>12) {// NON_COMPLIANT
46+
}
4047
}

‎c/misra/test/rules/RULE-7-4/StringLiteralAssignedToNonConstChar.expected‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
| test.c:58:5:58:22 | return ... | wchar_t * function w_sample3 is returning a string literal. |
77
| test.c:69:3:69:9 | call to sample4 | char * parameter of sample4 is passed a string literal. |
88
| test.c:78:3:78:11 | call to w_sample4 | wchar_t * parameter of w_sample4 is passed a string literal. |
9+
| test.c:91:3:91:11 | call to w_sample7 | char * parameter of w_sample7 is passed a string literal. |

‎c/misra/test/rules/RULE-7-4/test.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,16 @@ void w_call45() {
7979
w_sample5(L"string9");// COMPLIANT: passing string literal to const char*
8080
}
8181

82+
voidw_sample6(intx, ...) {}
83+
84+
voidw_call6() {
85+
w_sample6(1,"string10");// COMPLIANT by first (and only) exception
86+
}
87+
88+
voidw_sample7(char*x, ...) {}
89+
90+
voidw_call7() {
91+
w_sample7("string11",1);// NON_COMPLIANT, does not fit exceptional case
92+
}
93+
8294
intmain() {return0; }

‎c/misra/test/rules/RULE-8-3/function1.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ a f21(wi w, wi h) { // NON_COMPLIANT
2424

2525
voidf22(intf22b,intf22a) {// NON_COMPLIANT
2626
return;
27+
}
28+
29+
voidf23(intf23a) {// COMPLIANT
30+
return;
2731
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp