2017-07-29 16:28:57 +02:00
|
|
|
// To test:
|
2020-02-11 18:00:41 +01:00
|
|
|
// ~/cppcheck/cppcheck --dump --suppress=uninitvar --suppress=uninitStructMember misra/misra-test.c --std=c89 && python3 ../misra.py -verify misra/misra-test.c.dump
|
2017-07-29 16:28:57 +02:00
|
|
|
|
|
|
|
#include "path\file.h" // 20.2
|
2020-02-12 17:11:57 +01:00
|
|
|
#include "file//.h" // 20.2
|
|
|
|
#include "file/*.h" // 20.2
|
|
|
|
#include "file'.h" // 20.2
|
|
|
|
#include <file,.h> // 20.2
|
|
|
|
#include "file,.h" // 20.2
|
2020-02-10 08:56:26 +01:00
|
|
|
|
2018-09-02 16:31:27 +02:00
|
|
|
#include /*abc*/ "file.h" // no warning
|
2020-02-10 08:56:26 +01:00
|
|
|
/*foo*/#include "file.h" // no warning
|
|
|
|
#include "./file.h" // no warning
|
|
|
|
#include \
|
|
|
|
"file.h"
|
|
|
|
#include /*abc*/ \
|
|
|
|
"file.h"
|
|
|
|
#include "fi" "le.h" // 20.3 (strings are concatenated after preprocessing)
|
|
|
|
#include "fi" <le.h> // 20.3
|
|
|
|
#include <fi> <le.h> // 20.3
|
2018-09-02 16:31:27 +02:00
|
|
|
#include PATH "file.h" // 20.3
|
2020-02-10 08:56:26 +01:00
|
|
|
#define H_20_3_ok "file.h"
|
|
|
|
#include H_20_3_ok
|
|
|
|
#include file.h // 20.3
|
|
|
|
#define H_20_3_bad file.h
|
|
|
|
#include H_20_3_bad // TODO: 20.3 Trac #9606
|
|
|
|
#include "//file.h" // 20.2
|
|
|
|
#include "//file.h" H_20_3_bad // 20.2 20.3
|
|
|
|
//#include H_20_3_bad // no warning
|
|
|
|
#include H_20_3_ok H_20_3_ok // 20.3
|
2018-09-02 16:05:37 +02:00
|
|
|
#include<file.h> // no warning
|
2020-02-10 08:56:26 +01:00
|
|
|
|
2017-07-29 16:28:57 +02:00
|
|
|
#include <setjmp.h> // 21.4
|
|
|
|
#include <signal.h> // 21.5
|
2018-05-20 14:44:12 +02:00
|
|
|
#include <stdio.h> //21.6
|
|
|
|
#include <wchar.h> //21.6
|
|
|
|
#include <time.h> // 21.10
|
2017-07-29 16:28:57 +02:00
|
|
|
#include <tgmath.h> // 21.11
|
2019-10-26 08:32:46 +02:00
|
|
|
#include <fenv.h>
|
2017-07-29 16:28:57 +02:00
|
|
|
|
2018-05-20 14:44:12 +02:00
|
|
|
|
2017-07-29 16:28:57 +02:00
|
|
|
typedef unsigned char u8;
|
|
|
|
typedef unsigned short u16;
|
|
|
|
typedef unsigned int u32;
|
2018-05-21 12:04:20 +02:00
|
|
|
typedef signed int s32;
|
2017-07-29 16:28:57 +02:00
|
|
|
typedef unsigned long long u64;
|
|
|
|
|
2019-10-03 21:15:00 +02:00
|
|
|
/* // */ // 3.1
|
|
|
|
/* /* */ // 3.1
|
2018-09-08 17:23:24 +02:00
|
|
|
////
|
2017-07-29 16:28:57 +02:00
|
|
|
|
2019-10-03 21:15:00 +02:00
|
|
|
// http://example.com // no warning
|
|
|
|
|
2019-11-18 06:56:30 +01:00
|
|
|
void misra_2_7_unused_param (int *param1, int unused_param) // 2.7
|
|
|
|
{
|
|
|
|
*param1 = 42U;
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_2_7_used_params (int *param1, int param2, int param3)
|
|
|
|
{
|
|
|
|
(void)param3;
|
|
|
|
*param1 = param2;
|
|
|
|
}
|
|
|
|
|
2019-10-16 11:31:42 +02:00
|
|
|
void misra_3_2(int enable)
|
|
|
|
{
|
|
|
|
// This won't generate a violation because of subsequent blank line \
|
2019-12-15 18:23:12 +01:00
|
|
|
|
2019-10-16 11:31:42 +02:00
|
|
|
int y = 0;
|
|
|
|
int x = 0; // 3.2 non-compliant comment ends with backslash \
|
|
|
|
if (enable != 0)
|
|
|
|
{
|
|
|
|
++x; // This is always executed
|
|
|
|
// 3.2 potentially non-compliant comment ends with trigraph resolved to backslash ??/
|
|
|
|
++y; // This is hidden if trigraph replacement is active
|
|
|
|
}
|
|
|
|
|
|
|
|
(void)printf("x=%i, y=%i\n", x, y);
|
|
|
|
}
|
|
|
|
|
2018-05-16 11:07:44 +02:00
|
|
|
extern int misra_5_1_extern_var_hides_var_x;
|
|
|
|
extern int misra_5_1_extern_var_hides_var_y; //5.1
|
2019-05-26 18:46:00 +02:00
|
|
|
int misra_5_1_var_hides_var________a;
|
2019-07-09 15:53:23 +02:00
|
|
|
int misra_5_1_var_hides_var________b; int misra_5_1_var_hides_var________b1; int misra_5_1_var_hides_var________b2; //5.1
|
|
|
|
int misra_5_1_var_hides_var________c; //5.1
|
|
|
|
int misra_5_1_var_hides_var________d; //5.1
|
|
|
|
int misra_5_1_var_hides_var________e; //5.1
|
2018-05-16 11:07:44 +02:00
|
|
|
|
2018-10-07 17:19:40 +02:00
|
|
|
extern const uint8_t misra_5_2_var1;
|
|
|
|
const uint8_t misra_5_2_var1 = 3; // no warning
|
|
|
|
static int misra_5_2_var_hides_var______31x;
|
2018-05-16 11:07:44 +02:00
|
|
|
static int misra_5_2_var_hides_var______31y;//5.2
|
|
|
|
static int misra_5_2_function_hides_var_31x;
|
|
|
|
void misra_5_2_function_hides_var_31y(void) {}//5.2
|
2019-12-15 18:23:12 +01:00
|
|
|
void foo(void)
|
2018-05-08 20:41:45 +02:00
|
|
|
{
|
|
|
|
int i;
|
2018-05-16 11:07:44 +02:00
|
|
|
switch(misra_5_2_func1()) //16.4 16.6
|
2018-05-08 20:41:45 +02:00
|
|
|
{
|
2019-12-15 18:23:12 +01:00
|
|
|
case 1:
|
2018-05-08 20:41:45 +02:00
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
2019-12-15 18:23:12 +01:00
|
|
|
for(i = 0; i < 10; i++)
|
2018-05-08 20:41:45 +02:00
|
|
|
{
|
2018-05-16 11:07:44 +02:00
|
|
|
if(misra_5_2_func3()) //14.4
|
2018-05-08 20:41:45 +02:00
|
|
|
{
|
2018-05-16 11:07:44 +02:00
|
|
|
int misra_5_2_var_hides_var_1____31x;
|
|
|
|
int misra_5_2_var_hides_var_1____31y;//5.2
|
2018-05-08 20:41:45 +02:00
|
|
|
}
|
|
|
|
}
|
2018-05-16 11:07:44 +02:00
|
|
|
} while(misra_5_2_func2()); //14.4
|
2019-12-15 18:23:12 +01:00
|
|
|
}
|
2018-05-08 20:41:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-16 11:07:44 +02:00
|
|
|
union misra_5_2_field_hides_field__63x { //19.2
|
|
|
|
int misra_5_2_field_hides_field__31x;
|
|
|
|
int misra_5_2_field_hides_field__31y;//5.2
|
2018-05-08 20:41:45 +02:00
|
|
|
};
|
2018-05-16 11:07:44 +02:00
|
|
|
struct misra_5_2_field_hides_field__63y { //5.2
|
|
|
|
int misra_5_2_field_hides_field1_31x;
|
|
|
|
int misra_5_2_field_hides_field1_31y;//5.2
|
2018-05-08 20:41:45 +02:00
|
|
|
};
|
2018-03-31 12:17:55 +02:00
|
|
|
const char *s41_1 = "\x41g"; // 4.1
|
|
|
|
const char *s41_2 = "\x41\x42";
|
2019-09-28 20:16:10 +02:00
|
|
|
const char *s41_3 = "\x41" "\x42";
|
|
|
|
const char *s41_4 = "\x41" "g";
|
|
|
|
const char *s41_5 = "\x41\xA";
|
|
|
|
const char *s41_6 = "\xA\x41";
|
|
|
|
const char *s41_7 = "\xAA\xg\x41"; // 4.1
|
|
|
|
const char *s41_8 = "\xAA\x\x41"; // 4.1
|
|
|
|
const char *s41_9 = "unknown\gsequence";
|
|
|
|
const char *s41_10 = "simple\nsequence";
|
|
|
|
const char *s41_11 = "string";
|
2019-05-22 14:33:59 +02:00
|
|
|
int c41_3 = '\141t'; // 4.1
|
|
|
|
int c41_4 = '\141\t';
|
2019-09-28 20:16:10 +02:00
|
|
|
int c41_5 = '\0';
|
|
|
|
int c41_6 = '\0\t';
|
|
|
|
int c41_7 = '\12\t';
|
|
|
|
int c41_8 = '\0t'; // 4.1
|
|
|
|
int c41_9 = '\12';
|
|
|
|
int c41_10 = '\12\n';
|
|
|
|
int c41_11 = '\12n'; // 4.1
|
|
|
|
int c41_12 = '\12323'; // 4.1
|
|
|
|
int c41_13 = '\123\3';
|
|
|
|
int c41_14 = '\777\777';
|
|
|
|
int c41_15 = 'a';
|
|
|
|
|
|
|
|
void misra_4_1()
|
|
|
|
{
|
|
|
|
(void)printf("\x41g"); // 4.1
|
|
|
|
(void)printf("\x41\x42");
|
|
|
|
(void)printf("\x41" "g");
|
|
|
|
}
|
2018-03-31 12:17:55 +02:00
|
|
|
|
2019-10-09 08:26:05 +02:00
|
|
|
const char *s42_1 = "String containing trigraphs ??-??-??"; // 4.2
|
2019-10-31 15:03:18 +01:00
|
|
|
const char *s42_2 = "String containing trigraph???=preceded by question mark"; // 4.2
|
2019-10-09 08:26:05 +02:00
|
|
|
const char *s42_3 = "No trigraph?(?'?)";
|
|
|
|
|
|
|
|
void misra_4_2()
|
|
|
|
{
|
|
|
|
(void)printf("??=Trigraph\n"); // 4.2
|
|
|
|
(void)printf("No?/Trigraph\n");
|
|
|
|
}
|
|
|
|
|
2018-05-11 14:57:08 +02:00
|
|
|
#define misra_5_4_macro_hides_macro__31x 1
|
|
|
|
#define misra_5_4_param_hides_macro__31x 1
|
|
|
|
#define misra_5_4_macro_hides_macro__31y 2 //5.4
|
|
|
|
#define m1(misra_5_4_param_hides_macro__31y) 1 //5.4
|
|
|
|
#define m2(misra_5_4_param_hides_param__31x,misra_5_4_param_hides_param__31y) 1 //5.4
|
2019-08-31 07:53:16 +02:00
|
|
|
#ifdef misra_5_4_macro_hides_macro__31x
|
|
|
|
#define misra_5_4_macro 1 // no warning
|
|
|
|
#else
|
|
|
|
#define misra_5_4_macro 2 // no warning
|
|
|
|
#endif
|
2018-05-11 14:57:08 +02:00
|
|
|
|
|
|
|
#define misra_5_5_var_hides_macro____31x 1
|
|
|
|
#define misra_5_5_functionhides_macro31x 1
|
|
|
|
#define misra_5_5_param_hides_macro__31x 1
|
|
|
|
#define misra_5_5_tag_hides_macro____31x 1
|
|
|
|
#define misra_5_5_hides_macro________31x 1
|
|
|
|
|
|
|
|
int misra_5_5_var_hides_macro____31y; //5.5
|
2019-11-18 06:56:30 +01:00
|
|
|
void misra_5_5_functionhides_macro31y(int misra_5_5_param_hides_macro__31y){(void)misra_5_5_param_hides_macro__31y;} //5.5
|
2018-05-11 14:57:08 +02:00
|
|
|
struct misra_5_5_tag_hides_macro____31y { //5.5
|
|
|
|
int x;
|
|
|
|
};
|
2019-12-15 18:23:12 +01:00
|
|
|
void misra_5_5_func1()
|
2018-05-11 14:57:08 +02:00
|
|
|
{
|
2018-05-16 11:07:44 +02:00
|
|
|
switch(misra_5_5_func2()) //16.4 16.6
|
2018-05-11 14:57:08 +02:00
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
{
|
2019-12-15 18:23:12 +01:00
|
|
|
do
|
2018-05-11 14:57:08 +02:00
|
|
|
{
|
2018-05-16 11:07:44 +02:00
|
|
|
if(misra_5_5_func3()) //14.4
|
2018-05-11 14:57:08 +02:00
|
|
|
{
|
|
|
|
int misra_5_5_hides_macro________31y; //5.5
|
|
|
|
}
|
2018-05-16 11:07:44 +02:00
|
|
|
} while(misra_5_5_func2()); //14.4
|
2018-05-11 14:57:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-07-29 16:28:57 +02:00
|
|
|
|
|
|
|
|
|
|
|
void misra_7_1() {
|
|
|
|
int x = 066; // 7.1
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_7_3() {
|
2019-12-15 18:23:12 +01:00
|
|
|
long misra_7_3_a = 0l; //7.3
|
|
|
|
long misra_7_3_b = 0lU; //7.3
|
|
|
|
long long misra_7_3_c = 0Ull; //7.3
|
|
|
|
long long misra_7_3_d = 0ll; //7.3
|
|
|
|
long double misra_7_3_e = 7.3l; //7.3
|
2018-05-16 12:04:02 +02:00
|
|
|
}
|
|
|
|
|
2017-07-29 16:28:57 +02:00
|
|
|
|
|
|
|
extern int a811[]; // 8.11
|
|
|
|
|
2018-05-15 13:18:55 +02:00
|
|
|
enum misra_8_12_a { misra_a1 = 1, misra_a2 = 2, misra_a3, misra_a4 = 3 }; //8.12
|
|
|
|
enum misra_8_12_b { misra_b1, misra_b2, misra_b3 = 3, misra_b4 = 3 }; // no-warning
|
2018-06-13 06:54:30 +02:00
|
|
|
enum misra_8_12_c { misra_c1 = misra_a1, misra_c2 = 1 }; // no-warning
|
2019-06-01 13:10:20 +02:00
|
|
|
enum misra_8_12_d { misra_d1 = 1, misra_d2 = 2, misra_d3 = misra_d1 }; // no-warning
|
2019-08-04 12:24:28 +02:00
|
|
|
enum misra_8_12_e { misra_e1 = sizeof(int), misra_e2}; // no-crash
|
2017-07-29 16:28:57 +02:00
|
|
|
|
2019-11-18 06:56:30 +01:00
|
|
|
void misra_8_14(char * restrict str) {(void)str;} // 8.14
|
2017-07-29 16:28:57 +02:00
|
|
|
|
|
|
|
void misra_9_5() {
|
|
|
|
int x[] = {[0]=23}; // 9.5
|
|
|
|
}
|
|
|
|
|
2019-12-15 18:10:22 +01:00
|
|
|
typedef char misra_10_1_char_t;
|
|
|
|
#define MISRA_10_1_CHAR char
|
2019-11-27 09:09:17 +01:00
|
|
|
void misra_10_1(uint8_t u, char c1, char c2) {
|
2018-05-23 16:26:00 +02:00
|
|
|
int32_t i;
|
2019-11-27 09:09:17 +01:00
|
|
|
char c;
|
|
|
|
enum { E1 = 1 };
|
2018-05-23 16:26:00 +02:00
|
|
|
i = 3 << 1; // 10.1
|
2019-08-11 09:47:37 +02:00
|
|
|
i = (u & u) << 4; // no-warning
|
2019-12-15 18:10:22 +01:00
|
|
|
c = c1 & c2; // 10.1
|
2019-11-27 09:09:17 +01:00
|
|
|
c = c1 << 1; // 10.1
|
|
|
|
i = c1 > c2; // no-warning
|
|
|
|
i = E1 + i; // no-warning
|
2019-12-15 18:10:22 +01:00
|
|
|
|
|
|
|
char ch1 = 'a';
|
|
|
|
char ch2 = 'b';
|
|
|
|
char ch3;
|
|
|
|
ch3 = ch1 & ch2; // 10.1
|
|
|
|
|
|
|
|
misra_10_1_char_t ct1 = 'a';
|
|
|
|
misra_10_1_char_t ct2 = 'b';
|
|
|
|
misra_10_1_char_t ct3;
|
|
|
|
ct3 = ct1 & ct2; // 10.1
|
|
|
|
|
|
|
|
MISRA_10_1_CHAR cd1 = 'a';
|
|
|
|
MISRA_10_1_CHAR cd2 = 'b';
|
|
|
|
MISRA_10_1_CHAR cd3;
|
|
|
|
cd3 = cd1 & cd2; // 10.1
|
2018-05-23 16:26:00 +02:00
|
|
|
}
|
2019-12-21 07:40:15 +01:00
|
|
|
void misra_10_1_ternary()
|
|
|
|
{
|
|
|
|
int a;
|
|
|
|
uint8_t ui8;
|
|
|
|
uint16_t ui16;
|
|
|
|
int8_t i8;
|
|
|
|
int16_t i16;
|
|
|
|
|
2020-02-27 11:28:48 +01:00
|
|
|
a = ui16 << ui16; // 10.6
|
2019-12-21 07:40:15 +01:00
|
|
|
a = ui16 << (get_bool(42) ? ui16 : ui16);
|
|
|
|
a = ui16 << (get_bool(42) ? ui16 : (get_bool(34) ? ui16 : ui16)); // 10.4
|
|
|
|
a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : ui16) : ui16); // 10.4
|
|
|
|
a = ui16 << (get_bool(42) ? i16 : (get_bool(34) ? ui16 : ui16)); // 10.1
|
|
|
|
a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : i16) : ui16); // 10.1 10.4
|
|
|
|
a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : ui16) : i16); // 10.1
|
|
|
|
a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : ui8) : ui8); // 10.4
|
|
|
|
a = ui16 << (get_bool(42) ? (get_bool(34) ? i16 : ui8) : ui8); // 10.1 10.4
|
|
|
|
a = (get_bool(42) ? (get_bool(34) ? ui16 : ui8) : ui8) << ui16; // 10.4
|
|
|
|
a = (get_bool(42) ? (get_bool(34) ? i16 : ui8) : ui8) << ui16; // 10.1 10.4
|
|
|
|
a = (get_bool(42) ? (get_bool(34) ? ui16 : i8) : ui8) << ui16; // 10.1 10.4
|
|
|
|
a = (get_bool(42) ? (get_bool(34) ? ui16 : ui8) : i8) << ui16; // 10.1
|
|
|
|
a = (get_bool(42) ? (get_bool(34) ? ui16 : ui8) : ui8) << (get_bool(19) ? ui16 : ui8); // 10.4
|
|
|
|
a = (get_bool(42) ? (get_bool(34) ? i16 : ui8) : ui8) << (get_bool(19) ? ui16 : ui8); // 10.1 10.4
|
|
|
|
a = (get_bool(42) ? (get_bool(34) ? ui16 : ui8) : ui8) << (get_bool(19) ? i16 : ui8); // 10.1 10.4
|
|
|
|
|
|
|
|
}
|
2018-05-23 16:26:00 +02:00
|
|
|
|
2018-05-21 12:04:20 +02:00
|
|
|
void misra_10_4(u32 x, s32 y) {
|
|
|
|
z = x + 3; // 10.4
|
2018-06-09 08:23:41 +02:00
|
|
|
enum misra_10_4_enuma { misra_10_4_A1, misra_10_4_A2, misra_10_4_A3 } a;
|
2018-05-21 12:04:20 +02:00
|
|
|
enum misra_10_4_enumb { misra_10_4_B1, misra_10_4_B2, misra_10_4_B3 };
|
|
|
|
if ( misra_10_4_B1 > misra_10_4_A1 ) //10.4
|
|
|
|
{
|
2019-12-15 18:23:12 +01:00
|
|
|
;
|
2018-05-21 12:04:20 +02:00
|
|
|
}
|
2018-06-09 08:23:41 +02:00
|
|
|
z = x + y; //10.4
|
|
|
|
z = (a == misra_10_4_A3) ? x : y; //10.4
|
|
|
|
z = (a == misra_10_4_A3) ? y : y; // no-warning
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
2019-11-27 09:09:17 +01:00
|
|
|
void misra_10_6(u8 x, u32 a, u32 b, char c1, char c2) {
|
2017-07-29 16:28:57 +02:00
|
|
|
u16 y = x+x; // 10.6
|
2018-05-24 22:28:36 +02:00
|
|
|
u16 z = ~u8 x ;//10.6
|
|
|
|
u32 c = ( u16) ( u32 a + u32 b ); //10.6
|
2019-11-27 09:09:17 +01:00
|
|
|
s32 i = c1 - c2; // FIXME: False positive for 10.6 (this is compliant). Trac #9488
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
2020-02-27 11:28:48 +01:00
|
|
|
void misra_10_6_1(uint32_t *a, uint16_t b, uint16_t c)
|
|
|
|
{
|
|
|
|
*a = b + c ; // 10.6
|
|
|
|
}
|
2017-07-29 16:28:57 +02:00
|
|
|
|
2018-05-28 12:58:19 +02:00
|
|
|
void misra_10_8(u8 x, s32 a, s32 b) {
|
2017-07-29 16:28:57 +02:00
|
|
|
y = (u16)x;
|
|
|
|
y = (u16)(x+x); // 10.8
|
2018-05-28 12:58:19 +02:00
|
|
|
y = (u16) (a + b) //10.8
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
2018-05-23 10:14:17 +02:00
|
|
|
struct Fred {}; struct Wilma {};
|
|
|
|
void misra_11_3(u8* p, struct Fred *fred) {
|
2017-07-29 16:28:57 +02:00
|
|
|
x = (u64*)p; // 11.3
|
2018-05-23 10:14:17 +02:00
|
|
|
struct Wilma *wilma = (struct Wilma *)fred; // 11.3
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void misra_11_4(u8*p) {
|
|
|
|
u64 y = (u64)p; // 11.4
|
2018-05-22 09:07:48 +02:00
|
|
|
u8 *misra_11_4_A = ( u8 * ) 0x0005;// 11.4
|
|
|
|
s32 misra_11_4_B;
|
|
|
|
u8 *q = ( u8 * ) misra_11_4_B; // 11.4
|
|
|
|
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void misra_11_5(void *p) {
|
2018-05-22 14:32:00 +02:00
|
|
|
u16 *p16;
|
2017-07-29 16:28:57 +02:00
|
|
|
x = (u8 *)p; // 11.5
|
2018-05-23 10:14:17 +02:00
|
|
|
p16 = p; // 11.5
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void misra_11_6() {
|
|
|
|
void *p;
|
2018-05-30 12:44:20 +02:00
|
|
|
p = (void*)123; // 11.6
|
|
|
|
x = (u64)p; // 11.6
|
|
|
|
p = ( void * )0; // no-warning
|
|
|
|
(void)p; // no-warning
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
2018-05-23 10:14:17 +02:00
|
|
|
|
|
|
|
void misra_11_7(int *p, float f) {
|
|
|
|
x = ( float ) p; //11.7
|
|
|
|
y = ( int * ) f; //11.7
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
2019-10-03 10:15:50 +02:00
|
|
|
void misra_11_7_extra(int *p, float f, bool b) {
|
|
|
|
(void) p; // no-warning
|
|
|
|
(void) f; // no-warning
|
2019-11-18 06:56:30 +01:00
|
|
|
(void) b; // no-warning
|
2019-10-03 10:15:50 +02:00
|
|
|
}
|
|
|
|
|
2019-11-18 06:56:30 +01:00
|
|
|
char * misra_11_8_const(const char *str) {(void)str;}
|
2017-07-29 16:28:57 +02:00
|
|
|
char * misra_11_8(const char *str) {
|
2019-07-13 15:09:50 +02:00
|
|
|
(void)misra_11_8_const(str); // no-warning
|
2017-07-29 16:28:57 +02:00
|
|
|
return (char *)str; // 11.8
|
|
|
|
}
|
|
|
|
|
2018-05-23 15:48:07 +02:00
|
|
|
#define MISRA_11_9_NULL_1 (1-1)
|
|
|
|
#define MISRA_11_9_NULL_2 ( void * ) 0
|
|
|
|
#define MISRA_11_9_NULL_3 NULL
|
|
|
|
void misra_11_9(){
|
|
|
|
int *p1 = (5-5); //11.9
|
|
|
|
int *p2 = MISRA_11_9_NULL_2 ; // no-warning
|
|
|
|
int *p3 = MISRA_11_9_NULL_3 ; // no-warning
|
|
|
|
if ( p1 == MISRA_11_9_NULL_1 ) //11.9
|
|
|
|
{
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-07-29 16:28:57 +02:00
|
|
|
|
|
|
|
void misra_12_1() {
|
|
|
|
sz = sizeof x + y; // 12.1
|
|
|
|
a = (b * c) + d;
|
|
|
|
a = b << c + d; // 12.1
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_12_2(u8 x) {
|
|
|
|
a = x << 8; // 12.2
|
|
|
|
}
|
|
|
|
|
2019-12-19 08:36:10 +01:00
|
|
|
static int misra_12_3_v1 = 0, misra_12_3_v2; // 12.3
|
|
|
|
static int misra_12_3_v3, misra_12_3_v4; // 12.3
|
|
|
|
enum misra_12_3_e1 { M123A1, M123B1, M123C1 };
|
|
|
|
enum misra_12_3_e2 { M123A2 = 3, M123B2 = 4, M123C2 };
|
|
|
|
typedef enum misra_12_3_e3 { M123A3 , M123B3, M123C3 } misra_12_3_e3_t;
|
|
|
|
typedef enum { M123A4 , M123B4, M123C4 } misra_12_3_e4_t;
|
|
|
|
struct misra_12_3_s1 { int a; int b; int c, d; };
|
|
|
|
static struct misra_12_3_s1 misra_12_3_s1_inst = {
|
|
|
|
3,
|
|
|
|
4, 5,
|
|
|
|
6, // no warning
|
|
|
|
};
|
|
|
|
typedef struct misra_12_3_s2 { int a; int b; int c, d; } misra_12_3_s2_t;
|
|
|
|
typedef struct { int a; int b; int c, d; } misra_12_3_s3_t;
|
|
|
|
void misra_12_3_fn1(int, int); static int misra_12_3_v5, misra_12_4_v6; // 12.3
|
2019-12-19 15:55:51 +01:00
|
|
|
void misra_12_3_fn2(int a, int b) // 2.7
|
|
|
|
{ int d, e; } // 12.3
|
2019-12-19 08:36:10 +01:00
|
|
|
int misra_12_3_fn3(int a, int b) { return a+b;} static int misra_12_3_v5, misra_12_4_v6; // 12.3
|
2019-12-19 15:55:51 +01:00
|
|
|
void misra_12_3_fn4(const uint32_t value, uint8_t * const y) {} // 2.7
|
|
|
|
uint32_t misra_12_3_fn5(const uint32_t * const, const uint8_t) {} // 2.7
|
|
|
|
extern void misra_12_3_fn6(const uint32_t value, uint8_t * const y);
|
|
|
|
extern uint32_t misra_12_3_fn7(const uint32_t * const, const uint8_t);
|
2019-12-19 08:36:10 +01:00
|
|
|
#define MISRA_12_3_FN3_1(A, B) (misra_12_3_fn3(A, B))
|
|
|
|
#define MISRA_12_3_FN3_2(A, B) (misra_12_3_fn3(A, \
|
|
|
|
B))
|
|
|
|
#define MISRA_12_3_FN3_2_MSG(x) x, fflush(stderr)
|
|
|
|
void misra_12_3(int, int, int); // no warning
|
|
|
|
void misra_12_3(int a, int b, int c) { // no warning
|
|
|
|
int a1, a2; // 12.3
|
|
|
|
int a3; int a4; // no warning
|
|
|
|
int a5 = 9, a6; // 12.3
|
|
|
|
int a7, a8 = 11; // 12.3
|
|
|
|
int a9 = foo(), a10; // 12.3
|
|
|
|
int a11 = a = b = c; // 17.8
|
|
|
|
|
|
|
|
struct s1 {int a, b;}; int a12, a13; // 12.3
|
|
|
|
int a14, a15; misra_12_3_fn3(a14, a15); // 12.3 17.7
|
|
|
|
; int a16, a17; // 12.3
|
|
|
|
int a18; int a19, a20; // 12.3
|
|
|
|
int a21, a22; int a23; // 12.3
|
|
|
|
int a24, // 12.3
|
|
|
|
a25;
|
|
|
|
int a26
|
|
|
|
, a27; // 12.3
|
|
|
|
int a28
|
|
|
|
, // 12.3
|
|
|
|
a29;
|
|
|
|
|
|
|
|
struct misra_12_3_s2 a30 = {1, 2}, a31; // 12.3
|
|
|
|
struct misra_12_3_s2 a32, a33; // 12.3
|
|
|
|
struct misra_12_3_s2 a34, a35 = {1, 2}, a36; // 12.3
|
|
|
|
|
|
|
|
int a37 = MISRA_12_3_FN3_1(a34, a35), a38; // 12.3
|
|
|
|
int a39, a40 = MISRA_12_3_FN3_1(a34, a35); // 12.3
|
|
|
|
int a41 = MISRA_12_3_FN3_2(a34, a35), a42; // 12.3
|
|
|
|
int a43, a44 = MISRA_12_3_FN3_2(a34, a35); // 12.3
|
|
|
|
|
|
|
|
MISRA_12_3_FN3_2_MSG(fprintf(stderr, "test\n")); // 12.3
|
|
|
|
|
2017-07-29 16:28:57 +02:00
|
|
|
f((1,2),3); // TODO
|
2019-12-19 08:36:10 +01:00
|
|
|
|
|
|
|
for (i=0; i<10; i++, j++){} // 12.3
|
|
|
|
for (int i = 0, p = &a1; // 12.3 14.2
|
|
|
|
i < 42;
|
|
|
|
++i, ++p ) // 12.3
|
|
|
|
{}
|
2019-12-19 15:55:51 +01:00
|
|
|
|
|
|
|
// No false positives in local and extern function calls
|
|
|
|
misra_12_3_fn4(misra_12_3_fn5(&a1, 32), &a1);
|
|
|
|
misra_12_3_fn4(misra_12_3_fn7(&a1, 32), &a1);
|
|
|
|
misra_12_3_fn6(misra_12_3_fn5(&a1, 32), &a1);
|
|
|
|
misra_12_3_fn6(misra_12_3_fn7(&a1, 32), &a1);
|
2020-01-15 09:55:59 +01:00
|
|
|
|
|
|
|
const struct fun_t
|
|
|
|
{
|
|
|
|
int64_t x;
|
|
|
|
uint32_t y;
|
|
|
|
} moreFun[2U] =
|
|
|
|
{
|
|
|
|
{ 900000000000000LL, 0x20000UL },
|
|
|
|
{ 450000000000000LL, 0x10000UL }
|
|
|
|
};
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
2019-12-01 15:03:33 +01:00
|
|
|
#define MISRA12_4a 2000000000u
|
|
|
|
#define MISRA12_4b 4000000000u
|
2017-07-29 16:28:57 +02:00
|
|
|
void misra_12_4() {
|
2019-12-01 15:03:33 +01:00
|
|
|
uint32_t x;
|
|
|
|
bool t;
|
2017-07-29 16:28:57 +02:00
|
|
|
x = 123456u * 123456u; // 12.4
|
2019-12-01 15:03:33 +01:00
|
|
|
x = MISRA12_4a + MISRA12_4b; // 12.4
|
|
|
|
x = 0u - 1u; // 12.4
|
|
|
|
x = t ? 0u : (0u-1u); // 12.4
|
2019-12-08 18:52:52 +01:00
|
|
|
x = 556200230913ULL;
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
2018-05-22 13:11:39 +02:00
|
|
|
struct misra_13_1_t { int a; int b; };
|
2020-02-11 18:00:41 +01:00
|
|
|
uint8_t misra_13_1_x = 0;
|
|
|
|
void misra_13_1_bar(uint8_t a[2]);
|
2017-07-29 16:28:57 +02:00
|
|
|
void misra_13_1(int *p) {
|
2019-12-15 18:23:12 +01:00
|
|
|
volatile int v;
|
|
|
|
int a1[3] = {0, (*p)++, 2}; // 13.1
|
|
|
|
int a2[3] = {0, ((*p) += 1), 2}; // 13.1
|
|
|
|
int a3[3] = {0, ((*p) = 19), 2}; // 13.1
|
2020-02-11 18:00:41 +01:00
|
|
|
misra_13_1_bar((uint8_t[2]){ misra_13_1_x++, misra_13_1_x++ } ); // 13.1
|
2019-12-15 18:23:12 +01:00
|
|
|
int b[2] = {v,1};
|
|
|
|
struct misra_13_1_t c = { .a=4, .b=5 }; // no fp
|
2019-12-01 15:03:33 +01:00
|
|
|
volatile int vv;
|
|
|
|
int v = 42;
|
|
|
|
|
|
|
|
int a1[3] = { 0, (*p)++, 2 }; // 13.1
|
|
|
|
int a2[2] = { [0]=19, [1]=42 };
|
|
|
|
int a3[2] = { [0]=v, [1]=42 };
|
|
|
|
int a4[2] = { [0]=0, [1]=(v+=1) }; // 13.1
|
|
|
|
int a5[2] = { [0]=0, [1]=(v+1) };
|
|
|
|
int a6[2] = { v, 1 };
|
|
|
|
int a6[2] = { v >>= 3 }; // 13.1
|
|
|
|
int a7[2] = { v, ++v }; // 13.1
|
|
|
|
int a8[1] = { vv }; // TODO: 13.1 Trac #9504
|
|
|
|
|
|
|
|
struct misra_13_1_t c01 = { 4, 5 };
|
|
|
|
struct misra_13_1_t c02 = { 16 == 1, 5+1 };
|
|
|
|
struct misra_13_1_t c03 = { (v += 1), 5+1 }; // 13.1
|
|
|
|
struct misra_13_1_t c04 = { v <<= 1, 5+1 }; // 13.1
|
|
|
|
struct misra_13_1_t c05 = { v += 1, 5+1 }; // 13.1
|
|
|
|
struct misra_13_1_t c06 = { (4.5 + 0.5), 1 };
|
|
|
|
struct misra_13_1_t c07 = { (4.5 + 0.5), ++v }; // 13.1
|
|
|
|
struct misra_13_1_t c08 = { (int)4.5, 5 };
|
|
|
|
struct misra_13_1_t c09 = { (int)4.5+(*p)++, 5 }; // 13.1
|
|
|
|
struct misra_13_1_t c10 = { (int)4.5, (*p)++ }; // 13.1
|
|
|
|
struct misra_13_1_t c11 = { .a=4+1, .b=3/3 };
|
|
|
|
struct misra_13_1_t c12 = { .a=4, .b=5 };
|
|
|
|
struct misra_13_1_t c13 = { (*v)<<=(int)(4.5), .b=5 }; // 13.1
|
|
|
|
struct misra_13_1_t c14 = { (*p)/=(int)(4.5) }; // 13.1
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void misra_13_3() {
|
|
|
|
x = y++; // 13.3
|
|
|
|
}
|
|
|
|
|
2019-04-27 17:43:26 +02:00
|
|
|
#define STRING_DEF_13_4 "This is a string"
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
char string[sizeof(STRING_DEF_13_4)];
|
|
|
|
} s13_4_t;
|
|
|
|
|
|
|
|
static s13_4_t s13_4 =
|
|
|
|
{
|
|
|
|
.string = STRING_DEF_13_4 // no-warning
|
|
|
|
};
|
|
|
|
|
2017-07-29 16:28:57 +02:00
|
|
|
void misra_13_4() {
|
|
|
|
if (x != (y = z)) {} // 13.4
|
|
|
|
else {}
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_13_5() {
|
|
|
|
if (x && (y++ < 123)){} // 13.5
|
2019-12-15 18:23:12 +01:00
|
|
|
if (x || ((y += 19) > 33)){} // 13.5
|
|
|
|
if (x || ((y = 25) > 33)){} // 13.5 13.4
|
|
|
|
if (x || ((--y) > 33)){} // 13.5
|
2017-07-29 16:28:57 +02:00
|
|
|
else {}
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_13_6() {
|
2019-12-15 18:23:12 +01:00
|
|
|
int a = sizeof(x|=42); // 13.6
|
|
|
|
a = sizeof(--x); // 13.6 13.3
|
2017-07-29 16:28:57 +02:00
|
|
|
return sizeof(x++); // 13.6
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_14_1() {
|
|
|
|
for (float f=0.1f; f<1.0f; f += 0.1f){} // 14.1
|
2018-06-04 10:12:51 +02:00
|
|
|
float a = 0.0f;
|
|
|
|
int b = 10;
|
|
|
|
while ((a<100.0f) || (b > 100)) //14.1
|
|
|
|
{
|
|
|
|
a++;
|
|
|
|
}
|
|
|
|
do
|
|
|
|
{
|
|
|
|
;
|
|
|
|
} while ( a < 10.0f ); // no-warning
|
|
|
|
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
2019-11-30 11:27:31 +01:00
|
|
|
void misra_14_2_init_value(int32_t *var) {
|
|
|
|
*var = 0;
|
|
|
|
}
|
2019-12-15 18:23:12 +01:00
|
|
|
void misra_14_2_fn1(bool b) {
|
2017-07-29 16:28:57 +02:00
|
|
|
for (;i++<10;) {} // 14.2
|
|
|
|
for (;i<10;dostuff()) {} // TODO
|
2019-11-30 11:27:31 +01:00
|
|
|
int32_t g = 0;
|
2019-12-15 18:23:12 +01:00
|
|
|
int g_arr[42];
|
|
|
|
g += 2; // no-warning
|
2019-11-30 11:27:31 +01:00
|
|
|
for (int32_t i2 = 0; i2 < 8; ++i2) {
|
2019-12-15 18:23:12 +01:00
|
|
|
i2 += 2; // 14.2
|
|
|
|
i2 |= 2; // 14.2
|
|
|
|
g += 2;
|
|
|
|
i2 ^= 2; // 14.2
|
|
|
|
if (i2 == 2) {
|
|
|
|
g += g_arr[i2];
|
|
|
|
}
|
|
|
|
misra_14_2_init_value(&i2); // TODO: Fix false negative in function call
|
2019-11-30 11:27:31 +01:00
|
|
|
}
|
2019-12-15 18:23:12 +01:00
|
|
|
|
2019-11-30 11:27:31 +01:00
|
|
|
for (misra_14_2_init_value(&i); i < 10; ++i) {} // no-warning FIXME: False positive for 14.2 Trac #9491
|
2019-12-15 18:23:12 +01:00
|
|
|
|
2019-11-30 11:27:31 +01:00
|
|
|
bool abort = false;
|
|
|
|
for (i = 0; (i < 10) && !abort; ++i) { // no-warning
|
|
|
|
if (b) {
|
|
|
|
abort = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (;;) {} // no-warning
|
2019-12-15 18:23:12 +01:00
|
|
|
|
|
|
|
int x = 10;
|
|
|
|
for (int i = x; i < 42; i++) {
|
|
|
|
x++; // no warning
|
|
|
|
}
|
|
|
|
for (int i = (x - 3); i < 42; i++) {
|
|
|
|
x ^= 3; // no warning
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0, j = 19; i < 42; i++) { // 12.3 14.2
|
|
|
|
i += 12; // 14.2
|
|
|
|
j /= 3; // TODO: 14.2
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < 19; i++) {
|
|
|
|
for (int j = 0; j < 42; j++) {
|
|
|
|
i--; // 14.2
|
|
|
|
for (int k = j; k > 5; k--) {
|
|
|
|
i++; // 14.2
|
|
|
|
for (int h = 35; h > 5; k++) // 14.2
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static void misra_14_2_fn2()
|
|
|
|
{
|
|
|
|
int y = 0;
|
|
|
|
|
|
|
|
// Handle cases when i is not treated as loop counter according MISRA
|
|
|
|
// definition.
|
|
|
|
for (int i = 0, j = 19; y < 10, --j > 10; y++, j--) { // 14.2 12.3
|
|
|
|
i++; // no warning
|
|
|
|
}
|
|
|
|
for (int i = 0, j = 19; y < 10, --j > 10; y++, j--) { // 14.2 12.3
|
|
|
|
i++; // no warning
|
|
|
|
}
|
|
|
|
for (int i = 0; y < 10; y++) { // TODO: 14.2
|
|
|
|
i++; // no warning
|
|
|
|
}
|
|
|
|
for (int i = 0; i < 10; y++) { // TODO: 14.2
|
|
|
|
i++; // no warning
|
|
|
|
}
|
|
|
|
for (int i = 0; y < 10; i++) { // TODO: 14.2
|
|
|
|
i++; // no warning
|
|
|
|
}
|
|
|
|
for (int i = 0; i < 10; (y+=i)) {
|
|
|
|
i++; // no warning
|
|
|
|
}
|
|
|
|
|
|
|
|
// i is a loop counter according MISRA definition
|
|
|
|
for (int i = 0; i < 10; i++) {
|
|
|
|
i++; // 14.2
|
|
|
|
if (++i > 5) { // 14.2
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 0; i < 10; (i+=42)) {
|
|
|
|
i++; // 14.2
|
|
|
|
}
|
|
|
|
for (int i = 0; i < 10; (i|=y)) {
|
|
|
|
i++; // 14.2
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
2018-05-02 20:56:03 +02:00
|
|
|
struct {
|
|
|
|
unsigned int x:1;
|
|
|
|
unsigned int y:1;
|
2019-10-26 08:32:46 +02:00
|
|
|
} r14_4_struct;
|
2018-04-18 16:20:54 +02:00
|
|
|
void misra_14_4(bool b) {
|
2017-07-29 16:28:57 +02:00
|
|
|
if (x+4){} // 14.4
|
|
|
|
else {}
|
2018-04-18 16:20:54 +02:00
|
|
|
|
|
|
|
if (b) {}
|
|
|
|
else {}
|
2018-05-02 20:56:03 +02:00
|
|
|
|
2019-10-26 08:32:46 +02:00
|
|
|
if (r14_4_struct.x) {}
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void misra_15_1() {
|
|
|
|
goto a1; // 15.1
|
|
|
|
a1:
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_15_2() {
|
|
|
|
label:
|
|
|
|
goto label; // 15.2 15.1
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_15_3() {
|
|
|
|
if (x!=0) {
|
|
|
|
goto L1; // 15.3 15.1
|
|
|
|
if (y!=0) {
|
|
|
|
L1:
|
|
|
|
} else {}
|
|
|
|
} else {}
|
2020-02-16 00:03:18 +01:00
|
|
|
|
|
|
|
switch (x) {
|
|
|
|
case 0:
|
|
|
|
if (x == y) {
|
|
|
|
goto L2; // 15.3 15.1
|
|
|
|
}
|
|
|
|
goto L2; // 15.3 15.1
|
|
|
|
L3:
|
|
|
|
foo();
|
|
|
|
if (a == 0x42) {
|
|
|
|
// Compliant:
|
|
|
|
goto L3; // 15.1 15.2
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
y = x;
|
|
|
|
L2:
|
|
|
|
++x;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int misra_15_5() {
|
|
|
|
if (x!=0) {
|
|
|
|
return 1; // 15.5
|
|
|
|
} else {}
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_15_6() {
|
|
|
|
if (x!=0); // 15.6
|
|
|
|
else{}
|
|
|
|
|
|
|
|
#if A>1 // no-warning
|
|
|
|
(void)0;
|
|
|
|
#endif
|
|
|
|
|
2020-05-07 16:54:27 +02:00
|
|
|
#if A > 0x42
|
|
|
|
if (true) {
|
|
|
|
(void)0;
|
|
|
|
}
|
|
|
|
if (true)
|
|
|
|
#endif
|
|
|
|
{ (void)0; } // no-warning
|
|
|
|
|
2017-07-29 16:28:57 +02:00
|
|
|
do {} while (x<0); // no-warning
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_15_7() {
|
2018-10-01 20:16:48 +02:00
|
|
|
uint32_t var = 0;
|
|
|
|
uint32_t var2 = 0;
|
|
|
|
|
2017-10-26 08:47:53 +02:00
|
|
|
if (x!=0){} // no-warning
|
|
|
|
if (x!=0){} else if(x==1){} // 15.7
|
|
|
|
if (x!=0){} else if(x==1){}else{;} // no-warning
|
2018-10-01 20:16:48 +02:00
|
|
|
|
|
|
|
if (x!=0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var = 5u;
|
|
|
|
|
|
|
|
if (var != 5u)
|
|
|
|
{
|
|
|
|
var2 = 10u;
|
|
|
|
} // no-warning
|
|
|
|
}
|
2019-08-11 17:54:02 +02:00
|
|
|
|
|
|
|
if (a==2) {} else if (b==4) {} // 15.7
|
|
|
|
if (a==2) {} else { if (b==4) {} } // no-warning
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void misra_16_2() {
|
|
|
|
switch (x) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
while (y>4) {
|
|
|
|
case 2: break; // 16.2
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_16_3() {
|
|
|
|
switch (x) {
|
|
|
|
case 1:
|
|
|
|
case 2:
|
|
|
|
a=1;
|
|
|
|
case 3: // 16.3
|
|
|
|
a=2;
|
|
|
|
// fallthrough
|
|
|
|
case 5:
|
|
|
|
break;
|
2018-03-12 13:43:23 +01:00
|
|
|
case 7:
|
|
|
|
a=3;
|
|
|
|
[[fallthrough]];
|
|
|
|
case 8:
|
|
|
|
a=4;
|
|
|
|
break;
|
2018-03-12 15:16:57 +01:00
|
|
|
case 9:
|
|
|
|
if (a==b) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 10: // 16.3
|
|
|
|
return; // 15.5
|
|
|
|
case 11:
|
2018-04-24 09:28:24 +02:00
|
|
|
{ break; }
|
|
|
|
case 12:
|
2017-07-29 16:28:57 +02:00
|
|
|
default: break;
|
|
|
|
}
|
2019-08-11 19:08:57 +02:00
|
|
|
|
|
|
|
switch (x) {
|
|
|
|
case 1: // comment 1
|
|
|
|
{
|
|
|
|
a = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2: // comment 2
|
|
|
|
{
|
|
|
|
a = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2019-11-08 08:06:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (x) {
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
default: // 16.5
|
|
|
|
x++;
|
|
|
|
case 19: // 16.3
|
|
|
|
break;
|
|
|
|
case 20:
|
|
|
|
x + 2;
|
|
|
|
x + 3;
|
|
|
|
break;
|
2019-08-11 19:08:57 +02:00
|
|
|
}
|
2019-11-08 08:06:10 +01:00
|
|
|
switch (x) { // 16.6
|
|
|
|
default:;
|
|
|
|
} // 16.3
|
|
|
|
|
|
|
|
switch (x) { default:; } // 16.3 16.6
|
|
|
|
|
|
|
|
switch (x) {
|
|
|
|
case 20:
|
|
|
|
x + 2;
|
|
|
|
x + 3;
|
|
|
|
break;
|
|
|
|
case 21:
|
|
|
|
x + 2;
|
|
|
|
x + 3;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
} // 16.3
|
|
|
|
|
|
|
|
switch (x) { // 16.4 16.6
|
|
|
|
case 1:
|
|
|
|
x++;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
x++;
|
|
|
|
} // 16.3
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void misra_16_4() {
|
|
|
|
switch (x) { // 16.4
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_16_5() {
|
|
|
|
switch (x) {
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
default: // 16.5
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_16_6() {
|
|
|
|
switch (x) { // 16.6
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (x) {
|
2018-03-12 15:16:57 +01:00
|
|
|
case 1: break;
|
|
|
|
case 2: break;
|
|
|
|
default: break;
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
2018-05-03 10:59:09 +02:00
|
|
|
|
2018-05-04 22:30:24 +02:00
|
|
|
// No 16 6 in this switch:
|
2018-05-03 10:59:09 +02:00
|
|
|
switch (x) {
|
|
|
|
case A: return 1; // 15.5
|
|
|
|
case B: return 1; // 15.5
|
|
|
|
case C: return 1; // 15.5
|
|
|
|
default: return 2; // 15.5
|
|
|
|
}
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void misra_16_7() {
|
|
|
|
switch (x != 123) { // 16.7
|
|
|
|
case 1:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_17_1() {
|
|
|
|
va_list(); // 17.1
|
|
|
|
va_arg(); // 17.1
|
|
|
|
va_start(); // 17.1
|
|
|
|
va_end(); // 17.1
|
|
|
|
va_copy(); // 17.1
|
|
|
|
}
|
|
|
|
|
2019-07-13 15:09:50 +02:00
|
|
|
void misra_17_2_ok_1(void) { ; }
|
|
|
|
void misra_17_2_ok_2(void) {
|
|
|
|
misra_17_2_ok_1(); // no-warning
|
|
|
|
}
|
|
|
|
void misra_17_2_1(void) {
|
|
|
|
misra_17_2_ok_1(); // no-warning
|
|
|
|
misra_17_2_1(); // 17.2
|
|
|
|
misra_17_2_ok_2(); // no-warning
|
|
|
|
misra_17_2_1(); // 17.2
|
|
|
|
}
|
|
|
|
void misra_17_2_2(void) {
|
|
|
|
misra_17_2_3(); // 17.2
|
|
|
|
}
|
|
|
|
void misra_17_2_3(void) {
|
|
|
|
misra_17_2_4(); // 17.2
|
|
|
|
}
|
|
|
|
void misra_17_2_4(void) {
|
|
|
|
misra_17_2_2(); // 17.2
|
|
|
|
misra_17_2_3(); // 17.2
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_17_2_5(void) {
|
|
|
|
misra_17_2_ok_1(); // no-warning
|
|
|
|
misra_17_2_5(); // 17.2
|
|
|
|
misra_17_2_1(); // no-warning
|
|
|
|
}
|
|
|
|
|
2019-11-18 06:56:30 +01:00
|
|
|
void misra_17_6(int x[static 20]) {(void)x;} // 17.6
|
2017-07-29 16:28:57 +02:00
|
|
|
|
2019-05-22 21:39:33 +02:00
|
|
|
int calculation(int x) { return x + 1; }
|
|
|
|
void misra_17_7(void) {
|
|
|
|
calculation(123); // 17.7
|
|
|
|
}
|
|
|
|
|
2017-07-29 16:28:57 +02:00
|
|
|
void misra_17_8(int x) {
|
|
|
|
x = 3; // 17.8
|
|
|
|
}
|
|
|
|
|
2019-07-09 15:57:12 +02:00
|
|
|
void misra_18_4()
|
|
|
|
{
|
|
|
|
int b = 42;
|
|
|
|
int *bp = &b;
|
|
|
|
bp += 1; // 18.4
|
|
|
|
bp -= 2; // 18.4
|
|
|
|
int *p = bp - 2; // 18.4
|
|
|
|
int *ab = &b + 1; // 18.4
|
|
|
|
p = bp + p; // 18.4
|
|
|
|
bp = 1 + p + 1; // 18.4
|
|
|
|
b += 19; // no-warning
|
|
|
|
b = b + 9; // no-warning
|
|
|
|
}
|
|
|
|
|
2017-07-29 16:28:57 +02:00
|
|
|
void misra_18_5() {
|
|
|
|
int *** p; // 18.5
|
|
|
|
}
|
|
|
|
|
2019-07-01 07:00:43 +02:00
|
|
|
struct {
|
|
|
|
uint16_t len;
|
|
|
|
struct {
|
|
|
|
uint8_t data_1[]; // 18.7
|
|
|
|
} nested_1;
|
|
|
|
struct named {
|
|
|
|
struct {
|
|
|
|
uint8_t len_1;
|
|
|
|
uint32_t data_2[]; // 18.7
|
|
|
|
} nested_2;
|
|
|
|
uint8_t data_3[]; // 18.7
|
|
|
|
} nested_3;
|
2019-10-26 08:32:46 +02:00
|
|
|
} r18_7_struct;
|
2019-07-01 07:00:43 +02:00
|
|
|
struct {
|
|
|
|
uint16_t len;
|
|
|
|
uint8_t data_1[ 19 ];
|
|
|
|
uint8_t data_2[ ]; // 18.7
|
2019-10-26 08:32:46 +02:00
|
|
|
} r18_7_struct;
|
2019-07-01 07:00:43 +02:00
|
|
|
|
2017-07-29 16:28:57 +02:00
|
|
|
void misra_18_8(int x) {
|
|
|
|
int buf1[10];
|
|
|
|
int buf2[sizeof(int)];
|
|
|
|
int vla[x]; // 18.8
|
2019-10-26 17:29:38 +02:00
|
|
|
static const unsigned char arr18_8_1[] = UNDEFINED_ID;
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
union misra_19_2 { }; // 19.2
|
|
|
|
|
|
|
|
#include "notfound.h" // 20.1
|
|
|
|
|
|
|
|
#define int short // 20.4
|
2020-02-09 10:46:13 +01:00
|
|
|
#define inline "foo" // no warning in C90 standard
|
2017-07-29 16:28:57 +02:00
|
|
|
#undef X // 20.5
|
|
|
|
|
2019-04-11 10:50:07 +02:00
|
|
|
#define M_20_7_1(A) (A+1) // 20.7
|
|
|
|
#define M_20_7_2(A,B) (1+AB+2) // no warning
|
|
|
|
#define M_20_7_3(A) ((A)+A) // 20.7
|
2019-12-08 20:07:52 +01:00
|
|
|
#define M_20_7_4(A) x##A // 20.10 this test was written to see there are not FPs
|
2019-12-14 16:31:41 +01:00
|
|
|
#define M_20_7_5(A,B) f(A, B) // no warning
|
2020-04-27 09:10:58 +02:00
|
|
|
|
|
|
|
// Compliant: M is a structure member name, not an expression
|
|
|
|
struct { int a; } struct_20_7_s;
|
|
|
|
#define M_20_7_6(M) struct_20_7.M
|
|
|
|
#define M_20_7_7(M) (struct_20_7).M
|
|
|
|
|
2020-02-11 20:59:11 +01:00
|
|
|
#define MUL(a ,b ) ( a * b ) // 20.7
|
2019-04-11 10:50:07 +02:00
|
|
|
|
2019-12-08 20:07:52 +01:00
|
|
|
#define M_20_10(a) (#a) // 20.10
|
2019-04-11 10:36:02 +02:00
|
|
|
|
2018-05-03 22:53:06 +02:00
|
|
|
#else1 // 20.13
|
|
|
|
|
2019-04-08 18:26:17 +02:00
|
|
|
#ifdef A>1
|
|
|
|
# define somethingis 5 // no warning
|
|
|
|
# define func_20_13(v) (v) // no warning
|
|
|
|
#else
|
|
|
|
# definesomethingis 6 // 20.13
|
|
|
|
# def fun_2013(v) () // 20.13
|
|
|
|
#endif
|
|
|
|
|
2019-10-26 08:32:46 +02:00
|
|
|
#define _Incompatible 0xdeadbeef // 21.1
|
|
|
|
#define __Incompatible 0xdeadbeef // 21.1
|
|
|
|
#define __starts_with_lower 0xdeadbeef // 21.1
|
|
|
|
#define __MY_HEADER_ // 21.1
|
2019-11-08 17:20:37 +01:00
|
|
|
#define _macro_starts_with_lower 1 // no warning
|
2019-10-26 08:32:46 +02:00
|
|
|
static int _file_scope_id_21_1 = 42; // no warning
|
|
|
|
static int _file_scope_id_21_1_fn() { return 42; } // no warning
|
2019-11-08 17:20:37 +01:00
|
|
|
int misra_21_1() {
|
2020-02-09 16:22:26 +01:00
|
|
|
int _a = 42; // no warning: only directives affected
|
2019-11-08 17:20:37 +01:00
|
|
|
errno = EINVAL; // no warning
|
|
|
|
_a ++; // no warning
|
|
|
|
_exit(1); // no warning
|
|
|
|
return _a; // no warning
|
|
|
|
}
|
|
|
|
static int _misra_21_1_2(); // no warning
|
|
|
|
#define errno 11 // 21.1
|
2019-10-26 08:32:46 +02:00
|
|
|
|
2017-07-29 16:28:57 +02:00
|
|
|
void misra_21_3() {
|
|
|
|
p1=malloc(10); // 21.3
|
|
|
|
p2=calloc(10); // 21.3
|
|
|
|
realloc(10); // 21.3
|
|
|
|
free(p1); // 21.3
|
|
|
|
}
|
|
|
|
|
|
|
|
void misra_21_7() {
|
2019-05-22 21:39:33 +02:00
|
|
|
(void)atof(str); // 21.7
|
|
|
|
(void)atoi(str); // 21.7
|
|
|
|
(void)atol(str); // 21.7
|
|
|
|
(void)atoll(str); // 21.7
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void misra_21_8() {
|
|
|
|
abort(); // 21.8
|
2019-05-22 21:39:33 +02:00
|
|
|
(void)getenv("foo"); // 21.8
|
|
|
|
(void)system(""); // 21.8
|
2018-05-09 16:48:49 +02:00
|
|
|
exit(-1); // 21.8
|
2017-07-29 16:28:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void misra_21_9() {
|
2019-05-22 21:39:33 +02:00
|
|
|
(void)bsearch(key,base,num,size,cmp); // 21.9
|
2017-07-29 16:28:57 +02:00
|
|
|
qsort(base,num,size,cmp); // 21.9
|
|
|
|
}
|
2019-10-26 08:32:46 +02:00
|
|
|
|
|
|
|
void misra_21_12() {
|
|
|
|
int rc;
|
|
|
|
fexcept_t f; // 21.12
|
|
|
|
rc = feclearexcept(1); // 21.12
|
|
|
|
rc = fegetexceptflag(&f, 1); // 21.12
|
|
|
|
rc = feraiseexcept(1); // 21.12
|
|
|
|
rc = fesetexceptflag(&f, 1); // 21.12
|
|
|
|
rc = fetestexcept(1); // 21.12
|
|
|
|
}
|
|
|
|
|
2019-12-01 15:03:33 +01:00
|
|
|
// Large arrays for R13.1. Size exceeds default Python's max recursion depth.
|
|
|
|
static uint8_t misra_13_1_large_ok[1024] = {
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
|
|
|
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 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