Fixed #10447 (FP: misra-c2012-10.3)

This commit is contained in:
Daniel Marjamäki 2021-09-12 09:12:47 +02:00
parent c120c59912
commit 8de160a163
2 changed files with 7 additions and 1 deletions

View File

@ -445,7 +445,7 @@ def getEssentialTypeCategory(expr):
return "enum<" + expr.valueType.typeScope.className + ">"
if expr.variable:
typeToken = expr.variable.typeStartToken
while typeToken:
while typeToken and typeToken.isName:
if typeToken.str == 'char' and not typeToken.isSigned and not typeToken.isUnsigned:
return 'char'
if typeToken.valueType:
@ -506,6 +506,11 @@ def getEssentialType(expr):
return '%s %s' % (expr.valueType.sign, expr.valueType.type)
if expr.variable or isCast(expr):
typeToken = expr.variable.typeStartToken if expr.variable else expr.next
while typeToken and typeToken.isName:
if typeToken.str == 'char' and not typeToken.isSigned and not typeToken.isUnsigned:
return 'char'
typeToken = typeToken.next
if expr.valueType:
if expr.valueType.type == 'bool':
return 'bool'

View File

@ -678,6 +678,7 @@ static void misra_10_3(uint32_t u32a, uint32_t u32b) {
res = (uint16_t)(2U + 3U); // 10.3 10.8
res = (uint16_t)2U + (uint16_t)3U;
res = 0.1f; // 10.3
const char c = '0'; // no-warning
}
static void misra_10_4(u32 x, s32 y) {