1 // To test:
2 // ~/cppcheck/cppcheck --dump misra/misra-test.h --std=c89
3 // ~/cppcheck/cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test.c --std=c89 --platform=unix64 && python3 ../misra.py -verify misra/misra-test.c.dump
4
5 #include "path\file.h" // 20.2
6 #include "file/.h" // 20.2
7 #include "file/*.h" // 20.2
8 #include "file'.h" // 20.2
9 #include <file,.h> // 20.2
10 #include "file,.h" // 20.2
11
12 #include "misra-test.h"
13
14 #include /*abc*/ "file.h" // no warning
15 /*foo*/#include "file.h" // no warning
16 #include "./file.h" // no warning
17 #include \
18 "file.h"
19 #include /*abc*/ \
20 "file.h"
21 #include "fi" "le.h" // 20.3 (strings are concatenated after preprocessing)
22 #include "fi" <le.h> // 20.3
23 #include <fi> <le.h> // 20.3
24 #include PATH "file.h" // 20.3
25 #define H_20_3_ok "file.h"
26 #include H_20_3_ok
27 #include file.h // 20.3
28 #define H_20_3_bad file.h
29 #include H_20_3_bad // TODO: 20.3 Trac #9606
30 #include "/file.h" // 20.2
31 #include "/file.h" H_20_3_bad // 20.2 20.3
32 //#include H_20_3_bad // no warning
33 #include H_20_3_ok H_20_3_ok // 20.3
34 #include<file.h> // no warning
35
36 #include <setjmp.h> // 21.4
37 #include <signal.h> // 21.5
38 #include <stdio.h> //21.6
39 #include <wchar.h> //21.6
40 #include <time.h> // 21.10
41 #include <tgmath.h> // 21.11
42 #include <fenv.h>
43
44 // Check that the addon doesn't crash
45 typedef struct {
46 union { // 19.2
47 struct {
48 unsigned a : 2; // 8.1
49 unsigned : 14;
50 };
51 uint16_t value;
52 };
53 } STRUCT_BITS;
54
55 typedef unsigned char u8;
56 typedef unsigned short u16;
57 typedef unsigned int u32;
58 typedef signed int s32;
59 typedef unsigned long long u64;
60
61 static _Atomic int misra_1_4_var; // 1.4
misra_1_4_func(void)62 static _Noreturn void misra_1_4_func(void) // 1.4
63 {
64 if (0 != _Generic(misra_1_4_var)) {} // 1.4
65 printf_s("hello"); // 1.4
66 }
67
68
69 /* // */ // 3.1
70 /* /* */ // 3.1
71 ////
72
73 // http://example.com // no warning
74
misra_2_7_unused_param(int * param1,int unused_param)75 static void misra_2_7_unused_param (int *param1, int unused_param) // 2.7
76 {
77 *param1 = 42U;
78 }
79
misra_2_7_used_params(int * param1,int param2,int param3)80 static void misra_2_7_used_params (int *param1, int param2, int param3)
81 {
82 (void)param3;
83 *param1 = param2;
84 }
85
misra_2_7_a(int a,int b,int c,int d)86 static void misra_2_7_a(int a,
87 int b, // 2.7
88 int c,
89 int d) // 2.7
90 {
91 (void)a;
92 (void)c;
93 }
misra_2_7_b(int a,int b,int c,int d)94 static void misra_2_7_b(int a, int b, int c, // 2.7
95 int d) // 2.7
96 {
97 (void)a;
98 }
misra_2_7_c(int a,...)99 static void misra_2_7_c(int a, ...) { (void)a; }
misra_2_7_d(int)100 static void misra_2_7_d(int) { } // 2.7 8.2
101
misra_3_2(int enable)102 static void misra_3_2(int enable)
103 {
104 // This won't generate a violation because of subsequent blank line \
105
106 int y = 0;
107 int x = 0; // 3.2 non-compliant comment ends with backslash \
108 if (enable != 0)
109 {
110 ++x; // This is always executed
111 // 3.2 potentially non-compliant comment ends with trigraph resolved to backslash ??/
112 ++y; // This is hidden if trigraph replacement is active
113 }
114
115 (void)printf("x=%i, y=%i\n", x, y);
116 }
117
118 extern int misra_5_1_extern_var_hides_var_x;
119 extern int misra_5_1_extern_var_hides_var_y; //5.1
120 int misra_5_1_var_hides_var________a; // 8.4
121 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 8.4
122 int misra_5_1_var_hides_var________c; //5.1 8.4
123 int misra_5_1_var_hides_var________d; //5.1 8.4
124 int misra_5_1_var_hides_var________e; //5.1 8.4
125
126 extern const uint8_t misra_5_2_var1;
127 const uint8_t misra_5_2_var1 = 3;
128 static int misra_5_2_var_hides_var______31x;
129 static int misra_5_2_var_hides_var______31y;//5.2
130 static int misra_5_2_function_hides_var_31x;
misra_5_2_function_hides_var_31y(void)131 static void misra_5_2_function_hides_var_31y(void) {}//5.2
foo(void)132 static void foo(void)
133 {
134 int i;
135 switch(misra_5_2_func1()) //16.4 16.6
136 {
137 case 1:
138 {
139 do
140 {
141 for(i = 0; i < 10; i++)
142 {
143 if(misra_5_2_func3()) //14.4
144 {
145 int misra_5_2_var_hides_var_1____31x;
146 int misra_5_2_var_hides_var_1____31y;//5.2
147 }
148 }
149 } while(misra_5_2_func2()); //14.4
150 }
151 break;
152 }
153 }
154
155 union misra_5_2_field_hides_field__63x { //19.2
156 int misra_5_2_field_hides_field__31x;
157 int misra_5_2_field_hides_field__31y;//5.2
158 };
159 struct misra_5_2_field_hides_field__63y { //5.2
160 int misra_5_2_field_hides_field1_31x;
161 int misra_5_2_field_hides_field1_31y;//5.2
162 };
163 const char *s41_1 = "\x41g"; // 4.1 8.4
164 const char *s41_2 = "\x41\x42"; // 8.4
165 const char *s41_3 = "\x41" "\x42"; // 8.4
166 const char *s41_4 = "\x41" "g"; // 8.4
167 const char *s41_5 = "\x41\xA"; // 8.4
168 const char *s41_6 = "\xA\x41"; // 8.4
169 const char *s41_7 = "\xAA\xg\x41"; // 4.1 8.4
170 const char *s41_8 = "\xAA\x\x41"; // 4.1 8.4
171 const char *s41_9 = "unknown\gsequence"; // 8.4
172 const char *s41_10 = "simple\nsequence"; // 8.4
173 const char *s41_11 = "string"; // 8.4
174 int c41_3 = '\141t'; // 4.1 8.4
175 int c41_4 = '\141\t'; // 8.4
176 int c41_5 = '\0'; // 10.3 8.4
177 int c41_6 = '\0\t'; // 8.4
178 int c41_7 = '\12\t'; // 8.4
179 int c41_8 = '\0t'; // 4.1 8.4
180 int c41_9 = '\12'; // 8.4
181 int c41_10 = '\12\n'; // 8.4
182 int c41_11 = '\12n'; // 4.1 8.4
183 int c41_12 = '\12323'; // 4.1 8.4
184 int c41_13 = '\123\3'; // 8.4
185 // TODO int c41_14 = '\777\777';
186 int c41_15 = 'a'; // 10.3 8.4
187
misra_4_1(void)188 static void misra_4_1(void)
189 {
190 (void)printf("\x41g"); // 4.1
191 (void)printf("\x41\x42");
192 (void)printf("\x41" "g");
193 }
194
195 const char *s42_1 = "String containing trigraphs ??-??-??"; // 4.2 8.4
196 const char *s42_2 = "String containing trigraph???=preceded by question mark"; // 4.2 8.4
197 const char *s42_3 = "No trigraph?(?'?)"; // 8.4
198
misra_4_2(void)199 static void misra_4_2(void)
200 {
201 (void)printf("??=Trigraph\n"); // 4.2
202 (void)printf("No?/Trigraph\n");
203 }
204
205 #define misra_5_4_macro_hides_macro__31x 1
206 #define misra_5_4_param_hides_macro__31x 1
207 #define misra_5_4_macro_hides_macro__31y 2 //5.4
208 #define m1(misra_5_4_param_hides_macro__31y) 1 //5.4
209 #define m2(misra_5_4_param_hides_param__31x,misra_5_4_param_hides_param__31y) 1 //5.4
210 #ifdef misra_5_4_macro_hides_macro__31x
211 #define misra_5_4_macro 1 // no warning
212 #else
213 #define misra_5_4_macro 2 // no warning
214 #endif
215
216 #define misra_5_5_var_hides_macro____31x 1
217 #define misra_5_5_functionhides_macro31x 1
218 #define misra_5_5_param_hides_macro__31x 1
219 #define misra_5_5_tag_hides_macro____31x 1
220 #define misra_5_5_hides_macro________31x 1
221
222 int misra_5_5_var_hides_macro____31y; //5.5 8.4
misra_5_5_functionhides_macro31y(int misra_5_5_param_hides_macro__31y)223 static void misra_5_5_functionhides_macro31y(int misra_5_5_param_hides_macro__31y){(void)misra_5_5_param_hides_macro__31y;} //5.5
224 struct misra_5_5_tag_hides_macro____31y { //5.5
225 int x;
226 };
misra_5_5_func1(void)227 static void misra_5_5_func1(void)
228 {
229 switch(misra_5_5_func2()) //16.4 16.6
230 {
231 case 1:
232 {
233 do
234 {
235 if(misra_5_5_func3()) //14.4
236 {
237 int misra_5_5_hides_macro________31y; //5.5
238 }
239 } while(misra_5_5_func2()); //14.4
240 }
241 break;
242 }
243 }
244
245 typedef unsigned int UINT_TYPEDEF;
246 struct struct_with_bitfields
247 {
248 unsigned int a:2; // Compliant
249 signed int b:2; // Compliant
250 UINT_TYPEDEF c:2; // Compliant
251 int d:2; // 6.1 - plain int not compliant
252 signed long f:2; // 6.1 - signed long not compliant
253 unsigned int g:1; // Compliant
254 signed int h:1; // 6.2 - signed int with size 1 is not compliant
255 uint16_t i:1; // Compliant
256 };
257
misra6_1_fn(void)258 static void misra6_1_fn(void) {
259 // "Use" occurrence should not generate warnings
260 struct_with_bitfields s;
261 s.h = 61;
262 }
263
misra_7_1(void)264 static void misra_7_1(void) {
265 int x = 066; // 7.1
266 }
267
misra_7_2_call_test(int a,unsigned int b,unsigned int c)268 static void misra_7_2_call_test(int a, unsigned int b, unsigned int c) { } // 2.7
269
misra_7_2_call_va_test(int a,...)270 static void misra_7_2_call_va_test(int a, ...) { } // 2.7
271
misra_7_2(void)272 static void misra_7_2(void) {
273 uint32_t a = 2147483647;
274 const uint32_t b = 2147483648U;
275 const uint32_t c = 2147483648; // 7.2 10.3
276 uint32_t d = 2147483649; // 7.2 10.3
277
278 uint8_t e = 0x80; // 7.2 10.3
279 uint8_t f = 0x80U;
280 uint16_t g = 0x8000; // 7.2 10.3
281 uint16_t h = 0x8000U;
282 uint32_t i = 0x80000000; // 7.2
283 uint32_t j = 0x80000000U;
284 uint64_t k = 0x8000000000000000; // TODO 7.2
285 uint64_t l = 0x8000000000000000ULL;
286
287 uint32_t m = 1 + 0x80000000; // 7.2 10.4
288
289 misra_7_2_call_test(1, 2, 2147483648U);
290 misra_7_2_call_test(1, 2, 2147483648); // 7.2
291 misra_7_2_call_test(1, 0x80000000, 3); // 7.2
292 misra_7_2_call_va_test(1, 2, 3);
293 }
294
295 // The addon should not generate false positives for the identifiers.
296 struct misra_7_3_s
297 {
298 uint32_t ul_clka;
299 uint32_t test123l;
300 };
301
misra_7_3(void)302 static void misra_7_3(void) {
303 long misra_7_3_a = 0l; //7.3
304 long misra_7_3_b = 0lU; //7.3
305 long long misra_7_3_c = 0Ull; //7.3
306 long long misra_7_3_d = 0ll; //7.3
307 long double misra_7_3_e = 7.3l; //7.3
308 struct misra_7_3_s misra_7_3_f =
309 {
310 .ul_clka = 19U,
311 .test123l = 23U
312 };
313 }
314
315 typedef const char* MISRA_7_4_CHAR_CONST;
misra_7_4_return_const_type_def(void)316 static MISRA_7_4_CHAR_CONST misra_7_4_return_const_type_def (void) { return "return_typedef_const"; }
misra_7_4_return_non_const(void)317 static char *misra_7_4_return_non_const (void) { return 1 + "return_non_const"; } // 7.4 18.4
misra_7_4_return_const(void)318 static const char *misra_7_4_return_const (void) { return 1 + "return_const"; } // 18.4
319
misra_7_4_const_call(int a,const char * b)320 static void misra_7_4_const_call(int a, const char* b) { } // 2.7
misra_7_4_const_ptr_call(int a,const char const * b)321 static void misra_7_4_const_ptr_call(int a, const char const* b) { } // 2.7
misra_7_4_call(int a,char * b)322 static void misra_7_4_call(int a, char* b) { } // 2.7
323
misra_7_4(void)324 static void misra_7_4(void)
325 {
326 const char *a = "text a";
327 char* const b = "text_b"; // 7.4
328 char *c = "text c"; // 7.4
329 char *d = 1 + "text d"; // 7.4 18.4
330 char *e = "text e" + 1 + 2; // 7.4 18.4
331 char *f = 1 + "text f" + 2; // 7.4 18.4
332 const wchar_t *g = "text_g";
333 wchar_t *h = "text_h"; // 7.4
334
335 misra_7_4_const_call(1, ("text_const_call"));
336 misra_7_4_const_ptr_call(1, ("text_const_call"));
337 misra_7_4_call(1, "text_call"); // 7.4 11.8
338 }
339
340 const misra_8_1_a; // 8.1 8.4
341
342 static int misra_8_2_a (int n, ...);
343 extern int misra_8_2_b (int n);
344 extern int misra_8_2_c (int); // 8.2
345 static int misra_8_2_d (); // 8.2
346 static int misra_8_2_e (void);
misra_8_2_f(vec,n)347 static int misra_8_2_f (vec, n )
348 int *vec; // 8.2
349 int n; // 8.2
350 {
351 return vec[ n - 1 ];
352 }
353 static int misra_8_2_g ( /* comment */ ); // 8.2
354 static int misra_8_2_h ( /* comment 1 */ /* comment 2 */ ); // 8.2
355 static int misra_8_2_i ( /* comment */ void);
356 static int misra_8_2_j ( /* comment */ void /* comment */);
357 static int misra_8_2_k ( //
358 void);
359 static int misra_8_2_l ( // 8.2
360 );
361 static void misra_8_2_m(uint8_t * const x);
misra_8_2_m(uint8_t * const x)362 static void misra_8_2_m(uint8_t * const x)
363 {
364 (void)x;
365 }
366 int16_t ( *misra_8_2_p_a ) (); // 8.2 8.4
367 int16_t ( *misra_8_2_p_b ) (void); // 8.4
368 int16_t ( *misra_8_2_p_c ) (int); // 8.4
misra_8_2_n(int a)369 static int misra_8_2_n(int a)
370 { return a + 42; }
misra_8_2_o(const uint32_t a1,const uint8_t * const a2)371 static int misra_8_2_o(
372 const uint32_t a1,
373 const uint8_t *const a2
374 )
375 { return *a2 + a1; }
376 static int misra_8_2_p(
377 const uint32_t a1,
378 const uint8_t *const a2
379 );
380 static int misra_8_2_q
381 (); // 8.2
382
misra_8_4_foo(void)383 void misra_8_4_foo(void) {} // 8.4
misra_8_4_bar(void)384 static void misra_8_4_bar(void) {} // Declared in header
385 extern int16_t misra_8_4_count; // no-warning
386 int16_t misra_8_4_count = 0; // Compliant
387 extern uint8_t misra_8_4_buf1[13]; // no-warning
388 uint8_t misra_8_4_buf2[24]; // 8.4
389 typedef struct { uint16_t a; uint16_t b; } misra_8_4_struct;
390 extern misra_8_4_struct bar[42];
391 misra_8_4_struct bar[42]; // compliant
392
393 static int32_t misra_8_8 = 123;
394 extern int32_t misra_8_8; // 8.8
395
396 static int32_t misra_8_9_i; // 8.9
misra_8_9_foo(void)397 static int32_t misra_8_9_foo(void) { return misra_8_9_i++; }
398
misra_8_10_value(void)399 inline int32_t misra_8_10_value(void) { return 123; } // 8.10 8.4
400
401 extern int a811[]; // 8.11
402
403 enum misra_8_12_a { misra_a1 = 1, misra_a2 = 2, misra_a3, misra_a4 = 3 }; //8.12
404 enum misra_8_12_b { misra_b1, misra_b2, misra_b3 = 3, misra_b4 = 3 }; // no-warning
405 enum misra_8_12_c { misra_c1 = misra_a1, misra_c2 = 1 }; // no-warning
406 enum misra_8_12_d { misra_d1 = 1, misra_d2 = 2, misra_d3 = misra_d1 }; // no-warning
407 enum misra_8_12_e { misra_e1 = sizeof(int), misra_e2}; // no-crash
408
misra_8_14(char * restrict str)409 static void misra_8_14(char * restrict str) {(void)str;} // 8.14
410
misra_9_empty_or_zero_initializers(void)411 static void misra_9_empty_or_zero_initializers(void) {
412 int a[2] = {}; // 9.2
413 int b[2][2] = {}; // 9.2
414 int c[2][2] = { {} }; // 9.2 9.3
415 int d[2][2] = { {}, {} }; // 9.2
416 int e[2][2] = { { 1 , 2 }, {} }; // 9.2
417
418 int f[5] = { 0 };
419 int g[5][2] = { 0 };
420 int h[2][2] = { { 0 } }; // 9.3
421 int i[2][2] = { { 0 }, { 0 } };
422 int j[2][2] = { { 1, 2 }, { 0 } };
423 int k[2][2] = { [0] = { 1 , 2 }, { 0 } };
424 int l[1][2] = { { 0 }, [0] = { 1 } }; // 9.3 9.4
425
426 typedef struct {
427 int a;
428 int b;
429 } struct1;
430
431 struct1 m = { }; // 9.2
432 struct1 n = { 0 };
433 }
434
misra_9_string_initializers(void)435 static void misra_9_string_initializers(void) {
436 const char a[12] = { "Hello world" }; // 9.2
437 const char b[2][20] = "Hello world"; // 9.2 9.3
438 const char c[] = "Hello world";
439 const char d[15] = "Hello world";
440 const char e[1][12] = { "Hello world" };
441 const char *f[2] = { "Hello", [1] = "world" };
442 const char *g[1] = "Hello world"; // 9.2
443
444 const char h[2][15] = { { 0 }, "Hello world" };
445
446 char **str_p = &f[0];
447
448 char **i[1] = { str_p };
449 char **j[1] = { { str_p } }; // 9.2
450 }
451
misra_9_array_initializers(void)452 static void misra_9_array_initializers(void) {
453 char a[4] = { 1, 2, 3, 4 };
454 char b[2][2] = { {1, 2}, {3, 4} };
455 char c[2][2] = { 1, 2, 3, 4 }; // 9.2
456 char d[6] = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; // 9.2 9.3
457
458 char e[2][2] = { {1, 2}, {4} }; // 9.3
459 char f[2][2] = { 1, 2, 3 }; // 9.2 9.3
460 char g[2][2] = { {1, 2, 3, 4} }; // 9.3
461
462 char h[2][2] = { { 1, { 2 } }, { 3, { 5 } } }; // 9.2
463 char i[2][2] = { { 1, { 2 } }, { 3 } }; // 9.2 9.3
464 char j[2][3] = { { 1, { 2 }, 3 }, { 4, { 5 }, 6 } }; // 9.2
465 char k[2][3] = { { 1, { 2 }, 3 }, { 4, { 5 } } }; // 9.2 9.3
466 char l[3] = { 1, { 2, 3 } }; // 9.2 9.3
467 }
468
misra_9_array_initializers_with_designators(void)469 static void misra_9_array_initializers_with_designators(void) {
470 char a[1] = { [0][1] = 1 }; // 9.2
471 char b[1] = { [0] = { 1, 2 } }; // 9.2
472 char c[2][2] = { [0] = {1, 2, 3} };
473 char d[1][2] = { [0] = 1 }; // 9.2
474 char e[2][2] = { { 1, 2 }, [1][0] = {3, 4} }; // 9.2
475 char f[2] = { [0] = 1, 2 };
476 char g[2] = { [1] = 2, [0] = 1 };
477 char h[2][2] = { { 1, 2 }, [1] = { 3 } }; // 9.3
478 char i[2][2] = { { 1, 2 }, [1] = { 3, 4 } };
479 char j[2][2] = { { 1, 2 }, [1] = { [0] = 3 } };
480 char k[2][2] = { { 1, 2 }, [1][0] = 3 };
481 char l[2][2] = { { 1, 2 }, [1][0] = 3, 4}; // 9.2
482 char m[2][2] = { [0] = { [2] = 2 }, [1][5] = 4 };
483 char n[2][2] = { [0] = { 1 } }; // 9.3
484 char o[2][2] = { { 1 }, [1][0] = 3 }; // 9.3
485 char p[2][2] = { { 1, 2 }, { 3, 4 }, [1] = { 3 } }; // 9.3 9.4
486 // cppcheck-suppress unknownEvaluationOrder
487 char q[2][2] = { { 1, 2 }, { 1 }, [1] = { [1] = 3 } }; // 9.4
488 char r[2][2][2] = { [0][0] = { 1, 2 }, [1] = { [0] = {5, 6} } };
489 char s[2][2][2] = { [0][0] = { 1, 2 }, [1] = {5, 6, 7, 8}}; // 9.2
490 char t[2][2][2] = { [0][0] = { 1, 2 }, {3, 4}, [1] = {5, 6}}; // 9.2 9.3
491 char u[2][2][2] = { [0] = { 1, 2, {3, 4} } }; // 9.2
492 char v[2][2][2] = { [0] = { 1, 2, [1] = {3, 4} }}; // 9.2
493 }
494
misra_9_struct_initializers(void)495 static void misra_9_struct_initializers(void) {
496 typedef struct {
497 int i1;
498 int i2;
499 } struct1;
500
501 typedef struct {
502 char c1;
503 struct1 is1;
504 char c2[4];
505 } struct2;
506
507 typedef struct {
508 struct1 s[2][2];
509 } struct3;
510
511 typedef struct {
512 unknown_field_type f1;
513 unknown_field_type f2[2];
514 int f3[2];
515 } struct_with_unknown_fields;
516
517 struct3 sa[2] = { [1].s[1][0].i1 = 3, 4 }; // 9.2
518
519 struct1 sa = 1; // 9.2
520
521 struct1 sb = { 1, 2 };
522 struct2 sc = { 1, { 2 }, {4, 5, 6, 7} };
523 struct2 sd = { 1, { 2, 3 }, {4, 5, 6} }; // 9.3
524 struct2 se = { 1, 2, 3, 4, 5, 6, 7 }; // 9.2
525 struct2 sf = { 1, { 2, 3 }, 4, 5, 6, 7 }; // 9.2
526 struct2 sg = { 1, { 2 }, 4, 5, 6, 7 }; // 9.2
527 struct2 sh = { 1, { 2, 3 }, 4, 5, 6 }; // 9.2 9.3
528 struct2 si = { 1, 2, 3, {4,5,6,7} }; // 9.2
529
530 int a;
531 struct1 sj = { a = 1, 2 }; // 13.1
532
533 // Struct types
534 struct2 sta = { .is1 = sc }; // 9.2
535 struct2 stb = { .is1 = sb };
536 struct1 stc[1] = { sc }; // 9.2
537 struct1 std[1] = { sb };
538
539 // Struct designators
540 struct1 sda = { 1, .i2 = 2 };
541 struct2 sdb = { 1, { 2, .i2=3 }, .c2[1]=5 };
542 struct2 sdc = { 1, { 2, .i2=3 }, .c2 = { 5 } }; // 9.3
543 struct2 sdd = { 1, { 2, .i2=3 }, .c2 = 5 }; // 9.2
544 struct2 sde = { .is1 = { 2, 3 }, { 4, 5, 6, 7 } };
545
546 // Struct arrays
547 struct1 asa[2] = { {1,2}, {3,4} };
548 struct1 asb[2] = { {1}, {3,4} };
549 struct1 asc[2] = { {1,2} }; // 9.3
550 struct1 asd[2] = { 1,2, 3,4 }; // 9.2
551 struct1 ase[2] = { 1,2, 3 }; // 9.2
552 struct1 asf[2] = { 1,2 }; // 9.2 9.3
553 struct1 asg[2] = { [1].i1 = 3 };
554 struct3 ash[2] = { [1].s[1][0].i1 = 3 };
555 struct3 asi[2] = { [0] = { .s[0] = { { 1, 2 } }}}; // 9.3
556 struct3 asj[2] = { [0] = { .s[0] = { 1, 2 }}}; // 9.2 9.3
557
558 // Missing type information
559 dummy_struct dsa = { 1, .a = 2 };
560 dummy_struct dsb[2] = { {1,2}, {3,4} };
561 dummy_struct dsc[2][2] = { {1,2}, {3,4} };
562 dummy_struct dsd[2][2] = { 1, 2, 3, 4 }; // 9.2
563 dummy_struct dse[3] = { {1,2}, {3,4}, [1] = {5,6} }; // 9.3 9.4
564 dummy_struct dsf[] = { [0] = 1 }; // 9.5
565 dummy_struct dsg = { .a = {0}, .b = {0} };
566 dummy_struct dsh[2][2] = { { {.a = 0, .b = {0}}, { 0 } }, { { 0 }, {.a = 0, .b = {0}}} };
567
568 // Struct with fields of unknown type
569 struct_with_unknown_fields ufa = { 1, { 1, 2 }, { 1, 2 } };
570 struct_with_unknown_fields ufb = { 1, 1, 2 }; // 9.2
571 struct_with_unknown_fields[2] ufc = { {1, { 1, 2 }, { 1, 2 } },
572 { 2, { 1, 2 }, { 1, 2 } } };
573 struct_with_unknown_fields[2][2] ufd = { {1, { 1, 2 }, { 1, 2 } },
574 { 2, { 1, 2 }, { 1, 2 } } };
575 struct_with_unknown_fields[2] ufe = { 1, { 1, 2 }, { 1, 2 }, // TODO: 9.2
576 2, { 1, 2 }, { 1, 2 } };
577 struct_with_unknown_fields[3] uff = { { 1, { 1, 2 }, { 1, 2 }}, // TODO: 9.3 9.4
578 {2, { 1, 2 }, { 1, 2 }},
579 [1] = { 2, { 1, 2 }, { 1, 2 }} };
580
581 // Obsolete initialization syntax for GCC
582 struct1 os1 = { i1: 1, i2: 2 }; // 10.4 13.4
583 }
584
misra_9_broken_initializers(void)585 static void misra_9_broken_initializers(void) {
586 char a[UNKNOWN_MACRO] = { 19, 23, 0 }; // 18.8
587 }
588
misra_9_2(void)589 static void misra_9_2(void) {
590 union misra_9_2_union { // 19.2
591 char c;
592 struct1 i;
593 } u = { 3 }; // 19.2
594 }
595
misra_9_5(void)596 static void misra_9_5(void) {
597 char a[] = { 1, 2, 3 };
598 char b[] = { [2] = 5 }; // 9.5
599 char c[] = { 1, [1] = 5 }; // 9.5
600 char d[] = { [1] = 2, [0] = 1 }; // 9.5
601
602 char e[][2] = { { 1, 2 }, { 3, 4 } };
603 char f[][2] = { [1] = { 3, 4 } }; // 9.5
604 char g[][2] = { { 1, 2 }, [1] = { 3, 4 } }; // 9.5
605 char h[][2] = { [1] = { 1, 2 }, [0] = { 3, 4 } }; // 9.5
606 }
607
608 typedef char misra_10_1_char_t;
609 #define MISRA_10_1_CHAR char
misra_10_1(uint32_t u,char c1,char c2,uint8_t u8)610 static void misra_10_1(uint32_t u, char c1, char c2, uint8_t u8) {
611 int32_t i;
612 char c;
613 enum { E1 = 1 };
614 i = 3 << 1; // 10.1 10.6
615 i = (u & u) << 4; // no-warning
616 c = c1 & c2; // 10.1
617 c = c1 << 1; // 10.1
618 i = c1 > c2; // 10.3
619 i = E1 + i; // no-warning
620
621 char ch1 = 'a';
622 char ch2 = 'b';
623 char ch3;
624 ch3 = ch1 & ch2; // 10.1
625
626 misra_10_1_char_t ct1 = 'a';
627 misra_10_1_char_t ct2 = 'b';
628 misra_10_1_char_t ct3;
629 ct3 = ct1 & ct2; // 10.1
630
631 MISRA_10_1_CHAR cd1 = 'a';
632 MISRA_10_1_CHAR cd2 = 'b';
633 MISRA_10_1_CHAR cd3;
634 cd3 = cd1 & cd2; // 10.1
635
636 uint8_t temp1 = u8 & 0x42U; // no-warning
637 }
misra_10_1_ternary(void)638 static void misra_10_1_ternary(void)
639 {
640 int a;
641 uint8_t ui8;
642 uint16_t ui16;
643 int8_t i8;
644 int16_t i16;
645
646 a = ui16 << ui16; // 10.6
647 a = ui16 << (get_bool(42) ? ui16 : ui16);
648 a = ui16 << (get_bool(42) ? ui16 : (get_bool(34) ? ui16 : ui16)); // 10.4
649 a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : ui16) : ui16); // 10.4
650 a = ui16 << (get_bool(42) ? i16 : (get_bool(34) ? ui16 : ui16)); // 10.1
651 a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : i16) : ui16); // 10.1 10.4
652 a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : ui16) : i16); // 10.1
653 a = ui16 << (get_bool(42) ? (get_bool(34) ? ui16 : ui8) : ui8); // 10.4
654 a = ui16 << (get_bool(42) ? (get_bool(34) ? i16 : ui8) : ui8); // 10.1 10.4
655 a = (get_bool(42) ? (get_bool(34) ? ui16 : ui8) : ui8) << ui16; // 10.4
656 a = (get_bool(42) ? (get_bool(34) ? i16 : ui8) : ui8) << ui16; // 10.1 10.4
657 a = (get_bool(42) ? (get_bool(34) ? ui16 : i8) : ui8) << ui16; // 10.1 10.4
658 a = (get_bool(42) ? (get_bool(34) ? ui16 : ui8) : i8) << ui16; // 10.1
659 a = (get_bool(42) ? (get_bool(34) ? ui16 : ui8) : ui8) << (get_bool(19) ? ui16 : ui8); // 10.4
660 a = (get_bool(42) ? (get_bool(34) ? i16 : ui8) : ui8) << (get_bool(19) ? ui16 : ui8); // 10.1 10.4
661 a = (get_bool(42) ? (get_bool(34) ? ui16 : ui8) : ui8) << (get_bool(19) ? i16 : ui8); // 10.1 10.4
662 }
663
misra_10_2(void)664 static void misra_10_2(void) {
665 uint8_t u8a = 0;
666 char cha = 0;
667 int8_t s8a = 0;
668 int16_t s16a = 0;
669 float f32a = 0.0;
670 char res;
671
672 res = '0' + u8a; // Convert u8a to digit
673 res = s8a + '0';
674 res = cha - '0';
675 res = '0' - s8a;
676 res = cha + ':'; // 10.2
677
678 res = s16a - 'a'; // 10.2 10.3 10.4
679 res = '0' + f32a; // 10.2 10.4
680
681 // 10481 - crash
682 char buf[1] = {'f'};
683 x = buf[0] - '0';
684 }
685
misra_10_3(uint32_t u32a,uint32_t u32b)686 static void misra_10_3(uint32_t u32a, uint32_t u32b) {
687 uint8_t res;
688 res = u32a + u32b; // 10.3
689 res = (uint16_t)(2U + 3U); // 10.3 10.8
690 res = 2U + 3U; // no warning, utlr=unsigned char
691 res = 0.1f; // 10.3
692 const char c = '0'; // no-warning
693 }
694
misra_10_4(u32 x,s32 y)695 static void misra_10_4(u32 x, s32 y) {
696 z = x + 3; // 10.4
697 enum misra_10_4_enuma { misra_10_4_A1, misra_10_4_A2, misra_10_4_A3 } a;
698 enum misra_10_4_enumb { misra_10_4_B1, misra_10_4_B2, misra_10_4_B3 };
699 if ( misra_10_4_B1 > misra_10_4_A1 ) //10.4
700 {
701 ;
702 }
703 z = x + y; //10.4
704 z = (a == misra_10_4_A3) ? x : y; //10.4
705 z = (a == misra_10_4_A3) ? y : y; // no-warning
706
707 // #10499
708 const char buf[10] = {0};
709 if ('0' == buf[x]) // no-warning
710 {
711 }
712 }
713
misra_10_5(uint16_t x)714 static void misra_10_5(uint16_t x) {
715 // bool
716 res = (uint16_t) (x > 10u); // 10.5
717 res = (bool) 1u; // no-warning
718
719 // char <=> float
720 res = (char) 0.1f;
721 res = (float) 'x';
722 }
723
724 struct misra_10_6_s {
725 unsigned int a:4;
726 };
misra_10_6(u8 x,u32 a,u32 b,char c1,char c2)727 static void misra_10_6(u8 x, u32 a, u32 b, char c1, char c2) {
728 u16 y = x+x; // 10.6
729 u16 z = ~u8 x ;//10.6
730 u32 c = ( u16) ( u32 a + u32 b ); //10.6
731 s32 i = c1 - c2; // 10.3 FIXME: False positive for 10.6 (this is compliant). Trac #9488
732 struct misra_10_6_s s;
733 s.a = x & 1U; // no-warning (#10487)
734 }
misra_10_6_1(uint32_t * a,uint16_t b,uint16_t c)735 static void misra_10_6_1(uint32_t *a, uint16_t b, uint16_t c)
736 {
737 *a = b + c ; // 10.6
738 }
739
misra_10_7(uint16_t u16a,uint16_t u16b)740 static void misra_10_7(uint16_t u16a, uint16_t u16b) {
741 uint32_t u32a = 100u;
742 res = u32a * u16a + u16b; // 12.1 no-warning
743 res = (u32a * u16a) + u16b; // no-warning
744 res = u32a * ( ( uint32_t ) u16a + u16b ); // no-warning
745 res = u32a * (u16a + u16b); // 10.7
746 u32a *= u16a + u16b; // 10.7
747 u32a = ((uint32_t)4 * (uint32_t)2 * (uint32_t)4 ); // no-warning (#10488)
748 }
749
misra_10_8(u8 x,s32 a,s32 b)750 static void misra_10_8(u8 x, s32 a, s32 b) {
751 y = (u16)x;
752 y = (u16)(x+x); // 10.8
753 y = (u16) (a + b) //10.8
754 }
755
756 int (*misra_11_1_p)(void); // 8.4
757 void *misra_11_1_bad1 = (void*)misra_11_1_p; // 11.1 8.4
758
759 struct misra_11_2_s;
760 struct misra_11_2_t;
761
762 static struct misra_11_2_s * sp;
763 static struct misra_11_2_t * tp = sp; // 11.2
764
765 struct Fred {}; struct Wilma {};
misra_11_3(u8 * p,struct Fred * fred)766 static void misra_11_3(u8* p, struct Fred *fred) {
767 x = (u64*)p; // 11.3
768 struct Wilma *wilma = (struct Wilma *)fred; // 11.3
769 }
770
misra_11_4(u8 * p)771 static void misra_11_4(u8*p) {
772 u64 y = (u64)p; // 11.4
773 u8 *misra_11_4_A = ( u8 * ) 0x0005;// 11.4
774 s32 misra_11_4_B;
775 u8 *q = ( u8 * ) misra_11_4_B; // 11.4
776
777 }
778
misra_11_5(void * p)779 static void misra_11_5(void *p) {
780 u16 *p16;
781 x = (u8 *)p; // 11.5
782 p16 = p; // 11.5
783 }
784
misra_11_6(void)785 static void misra_11_6(void) {
786 void *p;
787 p = (void*)123; // 11.6
788 x = (u64)p; // 11.6
789 p = ( void * )0; // no-warning
790 (void)p; // no-warning
791 }
792
793
misra_11_7(int * p,float f)794 static void misra_11_7(int *p, float f) {
795 x = ( float ) p; //11.7
796 y = ( int * ) f; //11.7
797 }
798
misra_11_7_extra(int * p,float f,bool b)799 static void misra_11_7_extra(int *p, float f, bool b) {
800 (void) p; // no-warning
801 (void) f; // no-warning
802 (void) b; // no-warning
803 }
804
misra_11_8_const(const char * str)805 static void misra_11_8_const(const char *str) {(void)str;}
misra_11_8(const char * str)806 static char * misra_11_8(const char *str) {
807 (void)misra_11_8_const(str); // no-warning
808 return (char *)str; // 11.8
809 }
810
811 #define MISRA_11_9_NULL_1 (1-1)
812 #define MISRA_11_9_NULL_2 ( void * ) 0
813 #define MISRA_11_9_NULL_3 NULL
misra_11_9(void)814 static void misra_11_9(void) {
815 int *p1 = (5-5); //11.9
816 int *p2 = MISRA_11_9_NULL_2 ; // no-warning
817 int *p3 = MISRA_11_9_NULL_3 ; // no-warning
818 if ( p1 == MISRA_11_9_NULL_1 ) //11.9
819 {
820 ;
821 }
822
823 }
824
825
misra_12_1(void)826 static void misra_12_1(void) {
827 sz = sizeof x + y; // 12.1
828 a = (b * c) + d;
829 a = b << c + d; // 12.1
830 }
831
misra_12_2(u8 x)832 static void misra_12_2(u8 x) {
833 a = x << 8; // 12.2
834 }
835
836 static int misra_12_3_v1 = 0, misra_12_3_v2; // 12.3
837 static int misra_12_3_v3, misra_12_3_v4; // 12.3
838 enum misra_12_3_e1 { M123A1, M123B1, M123C1 };
839 enum misra_12_3_e2 { M123A2 = 3, M123B2 = 4, M123C2 };
840 typedef enum misra_12_3_e3 { M123A3 , M123B3, M123C3 } misra_12_3_e3_t;
841 typedef enum { M123A4 , M123B4, M123C4 } misra_12_3_e4_t;
842 struct misra_12_3_s1 { int a; int b; int c, d; }; // 12.3
843 static struct misra_12_3_s1 misra_12_3_s1_inst = {
844 3,
845 4, 5,
846 6, // no warning
847 };
848 typedef struct misra_12_3_s2 { int a; int b; int c, d; } misra_12_3_s2_t; // 12.3
849 typedef struct { int a; int b; int c, d; } misra_12_3_s3_t; // 12.3
850 static void misra_12_3_fn1(int, int); static int misra_12_3_v5, misra_12_4_v6; // 12.3 8.2
misra_12_3_fn2(int a,int b)851 static void misra_12_3_fn2(int a, int b) // 2.7
852 { int d, e; } // 12.3
misra_12_3_fn3(int a,int b)853 static int misra_12_3_fn3(int a, int b) { return a+b;} static int misra_12_3_v5, misra_12_4_v6; // 12.3
misra_12_3_fn4(const uint32_t value,uint8_t * const y)854 static void misra_12_3_fn4(const uint32_t value, uint8_t * const y) {} // 2.7
misra_12_3_fn5(const uint32_t * const,const uint8_t)855 static void misra_12_3_fn5(const uint32_t * const, const uint8_t) {} // 2.7 8.2
856 extern void misra_12_3_fn6(const uint32_t value, uint8_t * const y);
857 extern uint32_t misra_12_3_fn7(const uint32_t * const, const uint8_t); // 8.2
858 #define MISRA_12_3_FN3_1(A, B) (misra_12_3_fn3(A, B))
859 #define MISRA_12_3_FN3_2(A, B) (misra_12_3_fn3(A, \
860 B))
861 #define MISRA_12_3_FN3_2_MSG(x) x, fflush(stderr)
862 static void misra_12_3(int, int, int); // 8.2
misra_12_3(int a,int b,int c)863 void misra_12_3(int a, int b, int c) {
864 int a1, a2; // 12.3
865 int a3; int a4; // no warning
866 int a5 = 9, a6; // 12.3
867 int a7, a8 = 11; // 12.3
868 int a9 = foo(), a10; // 12.3
869 int a11 = a = b = c; // 17.8
870
871 struct s1 {int a, b;}; int a12, a13; // 12.3
872 int a14, a15; misra_12_3_fn3(a14, a15); // 12.3 17.7
873 ; int a16, a17; // 12.3
874 int a18; int a19, a20; // 12.3
875 int a21, a22; int a23; // 12.3
876 int a24, // 12.3
877 a25;
878 int a26
879 , a27; // 12.3
880 int a28
881 , // 12.3
882 a29;
883
884 struct misra_12_3_s2 a30 = {1, 2}, a31; // 12.3
885 struct misra_12_3_s2 a32, a33; // 12.3
886 struct misra_12_3_s2 a34, a35 = {1, 2}, a36; // 12.3
887
888 // cppcheck-suppress uninitStructMember
889 int a37 = MISRA_12_3_FN3_1(a34, a35), a38; // 12.3
890 int a39, a40 = MISRA_12_3_FN3_1(a34, a35); // 12.3
891 int a41 = MISRA_12_3_FN3_2(a34, a35), a42; // 12.3
892 int a43, a44 = MISRA_12_3_FN3_2(a34, a35); // 12.3
893
894 MISRA_12_3_FN3_2_MSG(fprintf(stderr, "test\n")); // 12.3
895
896 f((1,2),3); // TODO
897
898 for (i=0; i<10; i++, j++){} // 12.3
899 for (int i = 0, p = &a1; // 12.3 14.2
900 i < 42;
901 ++i, ++p ) // 12.3
902 {}
903
904 // No false positives in local and extern function calls
905 misra_12_3_fn4(misra_12_3_fn5(&a1, 32), &a1);
906 misra_12_3_fn4(misra_12_3_fn7(&a1, 32), &a1);
907 misra_12_3_fn6(misra_12_3_fn5(&a1, 32), &a1);
908 misra_12_3_fn6(misra_12_3_fn7(&a1, 32), &a1);
909 misra_12_3_fn7(maxlen, fn(va, unsigned long), false);
910 misra_12_3_fn8(maxlen, (unsigned long)((uintptr_t)fn(va, void*)), false);
911
912 const struct fun_t
913 {
914 int64_t x;
915 uint32_t y;
916 } moreFun[2U] =
917 {
918 { 900000000000000LL, 0x20000UL },
919 { 450000000000000LL, 0x10000UL }
920 };
921 }
922
923 #define MISRA12_4a 2000000000u
924 #define MISRA12_4b 4000000000u
misra_12_4(uint8_t t)925 static void misra_12_4(uint8_t t) {
926 x = 123456u * 123456u; // 12.4
927 x = MISRA12_4a + MISRA12_4b; // 12.4
928 x = 0u - 1u; // 12.4
929 x = t ? 0u : (0u-1u); // 12.4
930 }
931
932 struct misra_13_1_t { int a; int b; };
933 uint8_t misra_13_1_x = 0; // 8.4
934 static void misra_13_1_bar(uint8_t a[2]);
misra_13_1(int * p)935 static void misra_13_1(int *p) {
936 volatile int v;
937 int a1[3] = {0, (*p)++, 2}; // 13.1
938 int a2[3] = {0, ((*p) += 1), 2}; // 13.1
939 int a3[3] = {0, ((*p) = 19), 2}; // 13.1
940 misra_13_1_bar((uint8_t[2]){ misra_13_1_x++, misra_13_1_x++ } ); // 13.1
941 int b[2] = {v,1};
942 struct misra_13_1_t c = { .a=4, .b=5 }; // no fp
943 volatile int vv;
944 int v = 42;
945
946 int a1[3] = { 0, (*p)++, 2 }; // 13.1
947 int a2[2] = { [0]=19, [1]=42 };
948 int a3[2] = { [0]=v, [1]=42 };
949 int a4[2] = { [0]=0, [1]=(v+=1) }; // 13.1
950 int a5[2] = { [0]=0, [1]=(v+1) };
951 int a6[2] = { v, 1 };
952 int a6[2] = { v >>= 3 }; // 13.1 9.3
953 int a7[2] = { v, ++v }; // 13.1
954 int a8[1] = { vv }; // TODO: 13.1 Trac #9504
955
956 struct misra_13_1_t c01 = { 4, 5 };
957 struct misra_13_1_t c02 = { 16 == 1, 5+1 };
958 struct misra_13_1_t c03 = { (v += 1), 5+1 }; // 13.1
959 struct misra_13_1_t c04 = { v <<= 1, 5+1 }; // 13.1
960 struct misra_13_1_t c05 = { v += 1, 5+1 }; // 13.1
961 struct misra_13_1_t c06 = { (4.5 + 0.5), 1 };
962 struct misra_13_1_t c07 = { (4.5 + 0.5), ++v }; // 13.1
963 struct misra_13_1_t c08 = { (int)4.5, 5 };
964 struct misra_13_1_t c09 = { (int)4.5+(*p)++, 5 }; // 13.1
965 struct misra_13_1_t c10 = { (int)4.5, (*p)++ }; // 13.1
966 struct misra_13_1_t c11 = { .a=4+1, .b=3/3 };
967 struct misra_13_1_t c12 = { .a=4, .b=5 };
968 struct misra_13_1_t c13 = { (*v)<<=(int)(4.5), .b=5 }; // 13.1
969 struct misra_13_1_t c14 = { (*p)/=(int)(4.5) }; // 13.1
970 }
971
972 // Large arrays for R13.1. Size exceeds default Python's max recursion depth.
973 static uint8_t misra_13_1_large_ok[1024] = {
974 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
975 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF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0xFF, 0xFF,
1102 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
1103 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
1104 };
1105
misra_13_3(void)1106 static void misra_13_3(void) {
1107 x = y++; // 13.3
1108 }
1109
1110 #define STRING_DEF_13_4 "This is a string"
1111
1112 typedef struct
1113 {
1114 char string[sizeof(STRING_DEF_13_4)];
1115 } s13_4_t;
1116
1117 static s13_4_t s13_4 =
1118 {
1119 .string = STRING_DEF_13_4 // no-warning
1120 };
1121
misra_13_4(void)1122 static void misra_13_4(void) {
1123 if (x != (y = z)) {} // 13.4
1124 else {}
1125 }
1126
misra_13_5(void)1127 static void misra_13_5(void) {
1128 if (x && (y++ < 123)){} // 13.5
1129 if (x || ((y += 19) > 33)){} // 13.5
1130 if (x || ((y = 25) > 33)){} // 13.5 13.4
1131 if (x || ((--y) > 33)){} // 13.5
1132 else {}
1133 }
1134
misra_13_6(void)1135 static void misra_13_6(void) {
1136 int a = sizeof(x|=42); // 13.6
1137 a = sizeof(--x); // 13.6 13.3
1138 return sizeof(x++); // 13.6
1139 }
1140
misra_14_1(void)1141 static void misra_14_1(void) {
1142 for (float f=0.1f; f<1.0f; f += 0.1f){} // 14.1
1143 float a = 0.0f;
1144 int b = 10;
1145 while ((a<100.0f) || (b > 100)) //14.1
1146 {
1147 a++;
1148 }
1149 do
1150 {
1151 ;
1152 } while ( a < 10.0f ); // no-warning
1153
1154 }
1155
misra_14_2_init_value(int32_t * var)1156 static void misra_14_2_init_value(int32_t *var) {
1157 *var = 0;
1158 }
misra_14_2_fn1(bool b)1159 static void misra_14_2_fn1(bool b) {
1160 for (;i++<10;) {} // 14.2
1161 for (;i<10;dostuff()) {} // TODO
1162 int32_t g = 0;
1163 int g_arr[42];
1164 g += 2; // no-warning
1165 for (int32_t i2 = 0; i2 < 8; ++i2) {
1166 i2 += 2; // 14.2
1167 i2 |= 2; // 14.2
1168 g += 2;
1169 i2 ^= 2; // 14.2
1170 if (i2 == 2) {
1171 g += g_arr[i2];
1172 }
1173 misra_14_2_init_value(&i2); // TODO: Fix false negative in function call
1174 }
1175
1176 for (misra_14_2_init_value(&i); i < 10; ++i) {} // no-warning FIXME: False positive for 14.2 Trac #9491
1177
1178 bool abort = false;
1179 for (i = 0; (i < 10) && !abort; ++i) { // no-warning
1180 if (b) {
1181 abort = true;
1182 }
1183 }
1184 for (;;) {} // no-warning
1185
1186 int x = 10;
1187 for (int i = x; i < 42; i++) {
1188 x++; // no warning
1189 }
1190 for (int i = (x - 3); i < 42; i++) {
1191 x ^= 3; // no warning
1192 }
1193
1194 for (int i = 0, j = 19; i < 42; i++) { // 12.3 14.2
1195 i += 12; // 14.2
1196 j /= 3; // TODO: 14.2
1197 }
1198
1199 for (int i = 0; i < 19; i++) {
1200 for (int j = 0; j < 42; j++) {
1201 i--; // 14.2
1202 for (int k = j; k > 5; k--) {
1203 i++; // 14.2
1204 for (int h = 35; h > 5; k++) // 14.2
1205 {}
1206 }
1207 }
1208 }
1209 }
misra_14_2_fn2(void)1210 static void misra_14_2_fn2(void)
1211 {
1212 int y = 0;
1213
1214 // Handle cases when i is not treated as loop counter according MISRA
1215 // definition.
1216 for (int i = 0, j = 19; y < 10, --j > 10; y++, j--) { // 14.2 12.3
1217 i++; // no warning
1218 }
1219 for (int i = 0, j = 19; y < 10, --j > 10; y++, j--) { // 14.2 12.3
1220 i++; // no warning
1221 }
1222 for (int i = 0; y < 10; y++) { // TODO: 14.2
1223 i++; // no warning
1224 }
1225 for (int i = 0; i < 10; y++) { // TODO: 14.2
1226 i++; // no warning
1227 }
1228 for (int i = 0; y < 10; i++) { // TODO: 14.2
1229 i++; // no warning
1230 }
1231 for (int i = 0; i < 10; (y+=i)) {
1232 i++; // no warning
1233 }
1234
1235 // i is a loop counter according MISRA definition
1236 for (int i = 0; i < 10; i++) {
1237 i++; // 14.2
1238 if (++i > 5) { // 14.2
1239 break;
1240 }
1241 }
1242 for (int i = 0; i < 10; (i+=42)) {
1243 i++; // 14.2
1244 }
1245 for (int i = 0; i < 10; (i|=y)) {
1246 i++; // 14.2
1247 }
1248
1249 return 0;
1250 }
1251
1252 struct {
1253 unsigned int x:1;
1254 unsigned int y:1;
1255 } r14_4_struct; // 8.4
misra_14_4(bool b)1256 static void misra_14_4(bool b) {
1257 if (x+4){} // 14.4
1258 else {}
1259
1260 if (b) {}
1261 else {}
1262
1263 if (r14_4_struct.x) {}
1264 }
1265
misra_15_1(void)1266 static void misra_15_1(void) {
1267 goto a1; // 15.1
1268 a1:
1269 }
1270
misra_15_2(void)1271 static void misra_15_2(void) {
1272 label:
1273 goto label; // 15.2 15.1
1274 }
1275
misra_15_3(void)1276 static void misra_15_3(void) {
1277 if (x!=0) {
1278 goto L1; // 15.3 15.1
1279 if (y!=0) {
1280 L1:
1281 } else {}
1282 } else {}
1283
1284 switch (x) {
1285 case 0:
1286 if (x == y) {
1287 goto L2; // 15.3 15.1
1288 }
1289 goto L2; // 15.3 15.1
1290 L3:
1291 foo();
1292 if (a == 0x42) {
1293 // Compliant:
1294 goto L3; // 15.1 15.2
1295 }
1296 break;
1297 case 1:
1298 y = x;
1299 L2:
1300 ++x;
1301 break;
1302 default:
1303 break;
1304 }
1305 }
1306
misra_15_4(void)1307 static void misra_15_4(void) {
1308 misra_15_4_label:
1309 return;
1310
1311 int x = 0;
1312 int y = 0;
1313 int z = 0;
1314
1315 // Break on different loop scopes
1316 for (x = 0; x < 42; ++x) {
1317 if (x==1) {
1318 break;
1319 }
1320 for (y = 0; y < 42; ++y) { // 15.4
1321 if (y==1) {
1322 break;
1323 }
1324 if (y==2) {
1325 break;
1326 }
1327 for (z = 0; y < 42; ++z) {
1328 if (z==1) {
1329 break;
1330 }
1331 }
1332 }
1333 }
1334
1335 // Break in while loop
1336 do { // 15.4
1337 if(x == 1) {
1338 break;
1339 }
1340 if(x == 2) {
1341 break
1342 }
1343 x++;
1344 } while(x != 42);
1345
1346 // Break and goto in same loop
1347 for (int x = 0; x < 10; ++x) { // 15.4
1348 if (x == 1) {
1349 break;
1350 }
1351 if (x == 2) {
1352 goto misra_15_4_label; // 15.1 15.2
1353 }
1354 }
1355
1356 // Inner loop uses goto
1357 for (x = 0; x < 42; ++x) { // 15.4
1358 if (x==1) {
1359 break;
1360 }
1361 for (y = 0; y < 42; ++y) {
1362 if (y == 1) {
1363 goto misra_15_4_label; // 15.1 15.2
1364 }
1365 }
1366 }
1367
1368 // Allow switch with multiple breaks inside loop
1369 for (x = 0; x < 42; ++x) {
1370 switch (x) {
1371 case 1:
1372 break;
1373 default:
1374 break;
1375 }
1376 }
1377
1378 // Do not allow switch with multiple gotos inside loop
1379 for (x = 0; x < 42; ++x) { // 15.4
1380 switch (x) {
1381 case 1:
1382 goto misra_15_4_label; // 15.1 15.2
1383 break;
1384 default:
1385 goto misra_15_4_label; // 15.1 15.2
1386 break;
1387 }
1388 }
1389 }
1390
1391 static int misra_15_5(void) {
1392 if (x!=0) {
1393 return 1; // 15.5
1394 } else {}
1395 return 2;
1396 }
1397
1398 static void misra_15_6(void) {
1399 if (x!=0); // 15.6
1400 else{}
1401
1402 #if A>1 // 20.9
1403 (void)0;
1404 #endif
1405
1406 #if A > 0x42 // 20.9
1407 if (true) {
1408 (void)0;
1409 }
1410 if (true)
1411 #endif
1412 { (void)0; } // no-warning
1413
1414 do {} while (x<0); // no-warning
1415 }
1416
1417 #if defined(M_20_9) && M_20_9 > 1 // no-warning (#10380)
1418 #endif
1419
1420 static void misra_15_7(void) {
1421 uint32_t var = 0;
1422 uint32_t var2 = 0;
1423
1424 if (x!=0){} // no-warning
1425 if (x!=0){} else if(x==1){} // 15.7
1426 if (x!=0){} else if(x==1){}else{;} // no-warning
1427
1428 if (x!=0)
1429 {
1430 }
1431 else
1432 {
1433 var = 5u;
1434
1435 if (var != 5u)
1436 {
1437 var2 = 10u;
1438 } // no-warning
1439 }
1440
1441 if (a==2) {} else if (b==4) {} // 15.7
1442 if (a==2) {} else { if (b==4) {} } // no-warning
1443 }
1444
1445 static void misra_16_1(int32_t i) {
1446 switch (i) {
1447 int8_t x; // 16.1
1448 default: // 16.3 16.5
1449 break;
1450 if (i != 18) {} // 16.1
1451 case 1: // 16.3
1452 break;
1453 }
1454 }
1455
1456 static void misra_16_2(void) {
1457 switch (x) {
1458 default:
1459 break;
1460 case 1:
1461 while (y>4) {
1462 case 2: break; // 16.2
1463 }
1464 break;
1465 }
1466 }
1467
1468 static void misra_16_3(void) {
1469 switch (x) {
1470 case 1:
1471 case 2:
1472 a=1;
1473 case 3: // 16.3
1474 a=2;
1475 // fallthrough
1476 case 5:
1477 break;
1478 case 7:
1479 a=3;
1480 [[fallthrough]];
1481 case 8:
1482 a=4;
1483 break;
1484 case 9:
1485 if (a==b) {
1486 break;
1487 }
1488 case 10: // 16.3
1489 return; // 15.5
1490 case 11:
1491 { break; }
1492 case 12:
1493 default: break;
1494 }
1495
1496 switch (x) {
1497 case 1: // comment 1
1498 {
1499 a = 1;
1500 break;
1501 }
1502 case 2: // comment 2
1503 {
1504 a = 2;
1505 break;
1506 }
1507 default:
1508 {
1509 break;
1510 }
1511 }
1512
1513 switch (x) {
1514 case 1:
1515 break;
1516 default: // 16.5
1517 x++;
1518 case 19: // 16.3
1519 break;
1520 case 20:
1521 x + 2;
1522 x + 3;
1523 break;
1524 }
1525 switch (x) { // 16.6
1526 default:;
1527 } // 16.3
1528
1529 switch (x) { default:; } // 16.3 16.6
1530
1531 switch (x) {
1532 case 20:
1533 x + 2;
1534 x + 3;
1535 break;
1536 case 21:
1537 x + 2;
1538 x + 3;
1539 break;
1540 default:
1541 ;
1542 } // 16.3
1543
1544 switch (x) { // 16.4 16.6
1545 case 1:
1546 x++;
1547 break;
1548 case 2:
1549 x++;
1550 } // 16.3
1551 }
1552
1553 static void misra_16_4(void) {
1554 switch (x) { // 16.4
1555 case 1:
1556 break;
1557 case 2:
1558 break;
1559 }
1560 }
1561
1562 static void misra_16_5(void) {
1563 switch (x) {
1564 case 1:
1565 break;
1566 default: // 16.5
1567 break;
1568 case 2:
1569 break;
1570 }
1571 }
1572
1573 static void misra_16_6(void) {
1574 switch (x) { // 16.6
1575 default:
1576 break;
1577 }
1578
1579 switch (x) {
1580 case 1: break;
1581 case 2: break;
1582 default: break;
1583 }
1584
1585 // No 16 6 in this switch:
1586 switch (x) {
1587 case A: return 1; // 15.5
1588 case B: return 1; // 15.5
1589 case C: return 1; // 15.5
1590 default: return 2; // 15.5
1591 }
1592 }
1593
1594 static void misra_16_7(void) {
1595 switch (x != 123) { // 16.7
1596 case 1:
1597 break;
1598 default:
1599 break;
1600 }
1601 }
1602
1603 static void misra_17_1(void) {
1604 va_list(); // 17.1
1605 va_arg(); // 17.1
1606 va_start(); // 17.1
1607 va_end(); // 17.1
1608 va_copy(); // 17.1
1609 }
1610
1611 static void misra_17_2_ok_1(void) { ; }
1612 static void misra_17_2_ok_2(void) {
1613 misra_17_2_ok_1(); // no-warning
1614 }
1615 static void misra_17_2_1(void) {
1616 misra_17_2_ok_1(); // no-warning
1617 misra_17_2_1(); // 17.2
1618 misra_17_2_ok_2(); // no-warning
1619 misra_17_2_1(); // 17.2
1620 }
1621 static void misra_17_2_2(void) {
1622 misra_17_2_3(); // 17.2
1623 }
1624 static void misra_17_2_3(void) {
1625 misra_17_2_4(); // 17.2
1626 }
1627 static void misra_17_2_4(void) {
1628 misra_17_2_2(); // 17.2
1629 misra_17_2_3(); // 17.2
1630 }
1631
1632 static void misra_17_2_5(void) {
1633 misra_17_2_ok_1(); // no-warning
1634 misra_17_2_5(); // 17.2
1635 misra_17_2_1(); // no-warning
1636 }
1637
1638 static void misra_17_6(int x[static 20]) {(void)x;} // 17.6
1639
1640 static int calculation(int x) { return x + 1; }
1641 static void misra_17_7(void) {
1642 calculation(123); // 17.7
1643 }
1644
1645 static void misra_17_8(int x) {
1646 x = 3; // 17.8
1647 }
1648
1649 static void misra_18_4(void)
1650 {
1651 int b = 42;
1652 int *bp = &b;
1653 bp += 1; // 18.4
1654 bp -= 2; // 18.4
1655 int *p = bp - 2; // 18.4
1656 int *ab = &b + 1; // 18.4
1657 p = bp + p; // 18.4
1658 bp = 1 + p + 1; // 18.4
1659 b += 19; // no-warning
1660 b = b + 9; // no-warning
1661 }
1662
1663 static void misra_18_5(void) {
1664 int *** p; // 18.5
1665 }
1666
1667 struct {
1668 uint16_t len;
1669 struct {
1670 uint8_t data_1[]; // 18.7
1671 } nested_1;
1672 struct named {
1673 struct {
1674 uint8_t len_1;
1675 uint32_t data_2[]; // 18.7
1676 } nested_2;
1677 uint8_t data_3[]; // 18.7
1678 } nested_3;
1679 } r18_7_struct; // 8.4
1680 struct {
1681 uint16_t len;
1682 uint8_t data_1[ 19 ];
1683 uint8_t data_2[ ]; // 18.7
1684 } r18_7_struct; // 8.4
1685
1686 typedef enum {
1687 R18_8_ENUM_CONSTANT_0,
1688 R18_8_ENUM_CONSTANT_1,
1689 } r18_8_enum;
1690
1691 static void misra_18_8(int x) {
1692 int buf1[10];
1693 int buf2[sizeof(int)];
1694 int vla[x]; // 18.8
1695 static const unsigned char arr18_8_1[] = UNDEFINED_ID;
1696 static uint32_t enum_test_0[R18_8_ENUM_CONSTANT_0] = {0};
1697 }
1698
1699 union misra_19_2 { }; // 19.2
1700
1701 #include "notfound.h" // 20.1
1702
1703 #define int short // 20.4
1704 #define inline "foo" // no warning in C90 standard
1705 #undef X // 20.5
1706
1707 #define M_20_7_1(A) (A+1) // 20.7
1708 #define M_20_7_2(A,B) (1+AB+2) // no warning
1709 #define M_20_7_3(A) ((A)+A) // 20.7
1710 #define M_20_7_4(A) x##A // 20.10 this test was written to see there are not FPs
1711 #define M_20_7_5(A,B) f(A, B) // no warning
1712 #define M_20_7_6(x) a ## x = ( x ) // 20.10
1713 #define M_20_7_7(x) a = # x // 20.10
1714 #define M_20_7_8(x, fn) a = fn ( # x ) // 20.7 20.10
1715 #define M_20_7_9(x, fn) a = (fn) ( # x ) // 20.10
1716 #define M_20_7_10(A, B) (A " " B)
1717 #define M_20_7_11(A, B, C) (A " " B " " C)
1718 #define M_20_7_12(A, B, C) (A " " B + C) // 20.7
1719 #define M_20_7_13(A, B, C) (A + B " " C) // 20.7
1720 #define M_20_7_14(STRING1, STRING2) (STRING1 " " STRING2)
1721 #define M_20_7_15(STRING1, STRING2, STRING3) (STRING1 " " STRING2 " " STRING3)
1722 #define M_20_7_16(STRING1, STRING2, STRING3) (STRING1 " " STRING2 + STRING3) // 20.7
1723 #define M_20_7_17(STRING1, STRING2, STRING3) (STRING1 + STRING2 " " STRING3) // 20.7
1724
1725 // Compliant: M is a structure member name, not an expression
1726 struct { int a; } struct_20_7_s; // 8.4
1727 #define M_20_7_6(M) struct_20_7.M
1728 #define M_20_7_7(M) (struct_20_7).M
1729
1730 #define MUL(a ,b ) ( a * b ) // 20.7
1731
1732 #if __LINE__ // 20.8
1733 #elif 2+5 // 20.8
1734 #elif 2-2
1735 #endif
1736
1737 #if A // 20.9
1738 #elif B || C // 20.9
1739 #endif
1740
1741 #define M_20_10(a) (#a) // 20.10
1742
1743 #define M_20_11(a) # a ## 1 // 20.11 20.10
1744
1745 #define M_20_12_AA 0xffff
1746 #define M_20_12_BB(x) (x) + wow ## x // 20.12 20.10
1747 misra_20_12 = M_20_12_BB(M_20_12_AA);
1748
1749 #else1 // 20.13
1750
1751 #ifdef A
1752 # define somethingis 5 // no warning
1753 # define func_20_13(v) (v) // no warning
1754 #else
1755 # definesomethingis 6 // 20.13
1756 # def fun_2013(v) () // 20.13
1757 #endif
1758
1759 #define _Incompatible 0xdeadbeef // 21.1
1760 #define __Incompatible 0xdeadbeef // 21.1
1761 #define __starts_with_lower 0xdeadbeef // 21.1
1762 #define __MY_HEADER_ // 21.1
1763 #define _macro_starts_with_lower 1 // no warning
1764 static int _file_scope_id_21_1 = 42; // no warning
1765 static int _file_scope_id_21_1_fn(void) { return 42; } // no warning
1766 static int misra_21_1(void) {
1767 int _a = 42; // no warning: only directives affected
1768 errno = EINVAL; // no warning
1769 _a ++; // no warning
1770 _exit(1); // no warning
1771 return _a; // no warning
1772 }
1773 static int _misra_21_1_2(void); // no warning
1774 #define errno 11 // 21.1
1775 #undef errno // 20.5
1776
1777 #define __BUILTIN_SOMETHING 123 // 21.2 21.1
1778 extern void *memcpy ( void *restrict s1, const void *restrict s2, size_t n ); // 21.2 8.14
1779
1780 static void misra_21_3(void) {
1781 p1=malloc(10); // 21.3
1782 p2=calloc(10); // 21.3
1783 realloc(10); // 21.3
1784 free(p1); // 21.3
1785 }
1786
1787 static void misra_21_7(void) {
1788 (void)atof(str); // 21.7
1789 (void)atoi(str); // 21.7
1790 (void)atol(str); // 21.7
1791 (void)atoll(str); // 21.7
1792 }
1793
1794 static void misra_21_8(void) {
1795 abort(); // 21.8
1796 (void)getenv("foo"); // 21.8
1797 exit(-1); // 21.8
1798 }
1799
1800 static void misra_21_9(void) {
1801 (void)bsearch(key,base,num,size,cmp); // 21.9
1802 qsort(base,num,size,cmp); // 21.9
1803 }
1804
1805 static void misra_21_12(void) {
1806 int rc;
1807 fexcept_t f; // 21.12
1808 rc = feclearexcept(1); // 21.12
1809 rc = fegetexceptflag(&f, 1); // 21.12
1810 rc = feraiseexcept(1); // 21.12
1811 rc = fesetexceptflag(&f, 1); // 21.12
1812 rc = fetestexcept(1); // 21.12
1813 }
1814
1815 static void misra_21_14(uint8_t *x) {
1816 (void)strcpy(x, "123");
1817 (void)memcmp(x, y, 100); // 21.14
1818 (void)memcmp("abc", y, 100); // 21.14 21.16
1819 }
1820
1821 static void misra_21_15(uint8_t *x, uint16_t *y) {
1822 (void)memcpy(x, y, 10); // 21.15
1823 (void)memmove(x, y, 10); // 21.15
1824 (void)memcmp(x, y, 10); // 21.15
1825 }
1826
1827 struct misra_21_16_S { int a; int b; };
1828 static void misra_21_16_f1(struct misra_21_16_S *s1, struct misra_21_16_S *s2) {
1829 (void)memcmp(s1, s2, 10); // 21.16
1830 }
1831 static void misra_21_16_f2(char *x, char *y) {
1832 (void)memcmp(x, y, 10); // 21.16
1833 }
1834
1835 static void misra_21_19(void) {
1836 char *s = setlocale(LC_ALL,0); // 21.19
1837 const struct lconv *conv = localeconv ();
1838 conv->decimal_point = "^"; // 21.19
1839 }
1840
1841 static void misra_21_20(void) {
1842 const char *res1 = setlocale ( LC_ALL, 0 );
1843 (void) setlocale ( LC_MONETARY, "French" );
1844 if (res1) {} // 21.20 14.4
1845 }
1846
1847 static void misra_21_21(void) {
1848 (void)system("ls"); // 21.21
1849 }
1850
1851 static void misra_22_5(FILE *f) {
1852 int x = *f; // 22.5
1853 int y = f->pos; // 22.5
1854 }
1855
1856 static void misra_22_7(char ch)
1857 {
1858 if (EOF == ch) {} // 22.7
1859 }
1860
1861 static void misra_22_8(void)
1862 {
1863 (void)strtoll("123", NULL, 10); // 22.8
1864 if (errno == 0) {}
1865 }
1866
1867 static void misra_22_9(void)
1868 {
1869 errno = 0;
1870 (void)strtoll("123", NULL, 10); // 22.9
1871 }
1872
1873 static void misra_22_10(void)
1874 {
1875 errno = 0;
1876 f = atof ( "A.12" ); // 21.7
1877 if ( 0 == errno ) {} // 22.10
1878
1879 errno = 0;
1880 f = strtod ( "A.12", NULL );
1881 if ( 0 == errno ) {}
1882 }
1883