Misra; Remove 12.4 because the check is not implemented properly

This commit is contained in:
Daniel Marjamäki 2021-02-25 22:11:13 +01:00
parent 33427b61e1
commit ebf54ac53e
2 changed files with 4 additions and 25 deletions

View File

@ -1876,26 +1876,6 @@ class MisraChecker:
break
prev = prev.previous
def misra_12_4(self, data):
if typeBits['INT'] == 16:
max_uint = 0xffff
elif typeBits['INT'] == 32:
max_uint = 0xffffffff
else:
return
for token in data.tokenlist:
if not token.values:
continue
if (not isConstantExpression(token)) or (not isUnsignedInt(token)):
continue
for value in token.values:
if value.intvalue is None:
continue
if value.intvalue < 0 or value.intvalue > max_uint:
self.reportError(token, 12, 4)
break
def misra_13_1(self, data):
for token in data.tokenlist:
if simpleMatch(token, ") {") and token.next.astParent == token.link:
@ -3141,7 +3121,6 @@ class MisraChecker:
self.executeCheck(1201, self.misra_12_1, cfg)
self.executeCheck(1202, self.misra_12_2, cfg)
self.executeCheck(1203, self.misra_12_3, cfg)
self.executeCheck(1204, self.misra_12_4, cfg)
self.executeCheck(1301, self.misra_13_1, cfg)
self.executeCheck(1303, self.misra_13_3, cfg)
self.executeCheck(1304, self.misra_13_4, cfg)

View File

@ -732,10 +732,10 @@ void misra_12_3(int a, int b, int c) { // no warning
void misra_12_4() {
uint32_t x;
bool t;
x = 123456u * 123456u; // 12.4
x = MISRA12_4a + MISRA12_4b; // 12.4
x = 0u - 1u; // 12.4
x = t ? 0u : (0u-1u); // 12.4
x = 123456u * 123456u; // TODO 12.4
x = MISRA12_4a + MISRA12_4b; // TODO 12.4
x = 0u - 1u; // TODO 12.4
x = t ? 0u : (0u-1u); // TODO 12.4
x = 556200230913ULL;
foo(&volatile_macro_12_4); // no crash
}