cppcheck/addons/test/misra/misra-test-avr8.c
andymacg 5a136c3f38
Fix #11877 FP misra 10.4 On array member comparison (#5342)
I also changed the comment header to run tests on misra-test-avr8.c
because I thought that was the intention to use it like misra-test.c; if
not, I can revert.
2023-08-22 12:18:12 +02:00

30 lines
678 B
C

// To test:
// ~/cppcheck/cppcheck--dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test-avr8.c --std=c89 --platform=avr8 && python3 ../misra.py -verify misra/misra-test-avr8.c.dump
static void misra_10_4(void)
{
// #10480
const char buf[1] = {'f'};
const char c = '0';
x = buf[0] - c;
const char buf[2] = {0};
x = 'a' == buf[0]; // no-warning
typedef struct {
int t;
char buf[2];
} foo_t;
const foo_t cmd = {0};
x = 'b' == cmd.buf[0]; // no-warning
const foo_t * pcmd = &cmd;
x='c' == pcmd->buf[0]; // no-warning
(void)cmd.t;
}
static void misra_12_2(void) {
a = (((uint64_t)0xFF) << 32);
}