Misra: target MISRA C 2012

This commit is contained in:
Daniel Marjamäki 2017-04-11 14:45:38 +02:00
parent a26abfb8e4
commit bf209890cb
2 changed files with 177 additions and 895 deletions

View File

@ -1,58 +1,26 @@
/*
~/cppcheck/cppcheck --dump misra-test.c
python misra.py misra-test.c.dump
Expected output:
[misra-test.c:5] (style) misra: 11 Identifier is longer than 31 characters
[misra-test.c:9] (style) misra: 14 The type char shall always be declared as unsigned char or signed char
[misra-test.c:3] (style) misra: 15 Make sure the floating point implementation comply with a defined floating point standard
[misra-test.c:17] (style) misra: 33 The right hand of a && or || shall not have side effects
[misra-test.c:21] (style) misra: 34 The operands of a && or || shall be primary expressions
[misra-test.c:3] (style) misra: 41 The implementation of integer division in the chosen compiler should be determined, documented and taken into account.
[misra-test.c:25] (style) misra: 56 The goto statement shall not be used
[misra-test.c:29] (style) misra: 57 The continue statement shall not be used
*/
void misra11() {
void misra_5_1() {
int a123456789012345678901234567890; // no-warning
int a1234567890123456789012345678901; // 11
int a1234567890123456789012345678901; // 51
}
void misra14() {
char c; // 14
void misra_7_1() {
int x = 066; // 71
}
void misra19() {
int x = 066; // 19
void misra_13_5() {
if (x && (y++ < 123)){} // 135
}
void misra28() {
register int x = 3; // 28
void misra_14_4() {
if (x+4){} // 144
}
enum misra32 { A=1, B, C=10 }; // 32
enum misra32_ok1 { A, B, C };
enum misra32_ok2 { A=1, B, C };
void misra33() {
if (x && (y++ < 123)){} // 33
void misra_15_1() {
goto a1; // 151
}
void misra34() {
if (x+3 && y){} // 34
}
void misra56() {
goto a1; // 56
}
void misra57() {
continue; // 57
}
void misra58() {
while (1) {
if(x)
break; // 58
}
}

File diff suppressed because it is too large Load Diff