2017-04-08 19:00:50 +02:00
|
|
|
/*
|
|
|
|
~/cppcheck/cppcheck --dump misra-test.c
|
|
|
|
python misra.py misra-test.c.dump
|
|
|
|
*/
|
|
|
|
|
2017-04-11 14:45:38 +02:00
|
|
|
void misra_5_1() {
|
2017-04-08 19:00:50 +02:00
|
|
|
int a123456789012345678901234567890; // no-warning
|
2017-04-11 22:21:54 +02:00
|
|
|
int a1234567890123456789012345678901; // 5.1
|
2017-04-08 19:00:50 +02:00
|
|
|
}
|
|
|
|
|
2017-04-11 14:45:38 +02:00
|
|
|
void misra_7_1() {
|
2017-04-11 22:21:54 +02:00
|
|
|
int x = 066; // 7.1
|
2017-04-08 19:00:50 +02:00
|
|
|
}
|
|
|
|
|
2017-04-11 19:03:35 +02:00
|
|
|
void misra_7_3() {
|
2017-04-11 22:21:54 +02:00
|
|
|
int x = 12l; // 7.3
|
2017-04-12 19:07:10 +02:00
|
|
|
int x = 12lu; // 7.3
|
2017-04-11 22:21:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void misra_12_1() {
|
2017-04-12 16:19:13 +02:00
|
|
|
sz = sizeof x + y; // 12.1
|
2017-04-11 22:21:54 +02:00
|
|
|
a = (b * c) + d;
|
|
|
|
a = b << c + d; // 12.1
|
2017-04-11 19:03:35 +02:00
|
|
|
}
|
|
|
|
|
2017-04-12 20:18:54 +02:00
|
|
|
void misra_12_3() {
|
2017-04-12 21:45:39 +02:00
|
|
|
f((1,2),3); // TODO
|
2017-04-12 20:18:54 +02:00
|
|
|
for (i=0;i<10;i++,j++){} // 12.3
|
|
|
|
}
|
|
|
|
|
2017-04-11 14:45:38 +02:00
|
|
|
void misra_13_5() {
|
2017-04-11 22:21:54 +02:00
|
|
|
if (x && (y++ < 123)){} // 13.5
|
2017-04-09 10:11:54 +02:00
|
|
|
}
|
|
|
|
|
2017-04-11 14:45:38 +02:00
|
|
|
void misra_14_4() {
|
2017-04-11 22:21:54 +02:00
|
|
|
if (x+4){} // 14.4
|
2017-04-08 19:00:50 +02:00
|
|
|
}
|
|
|
|
|
2017-04-11 14:45:38 +02:00
|
|
|
void misra_15_1() {
|
2017-04-11 22:21:54 +02:00
|
|
|
goto a1; // 15.1
|
2017-04-08 19:00:50 +02:00
|
|
|
}
|
|
|
|
|