Skip to content

Commit 8de160a

Browse files
committed
Fixed #10447 (FP: misra-c2012-10.3)
1 parent c120c59 commit 8de160a

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

addons/misra.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def getEssentialTypeCategory(expr):
445445
return "enum<" + expr.valueType.typeScope.className + ">"
446446
if expr.variable:
447447
typeToken = expr.variable.typeStartToken
448-
while typeToken:
448+
while typeToken and typeToken.isName:
449449
if typeToken.str == 'char' and not typeToken.isSigned and not typeToken.isUnsigned:
450450
return 'char'
451451
if typeToken.valueType:
@@ -506,6 +506,11 @@ def getEssentialType(expr):
506506
return '%s %s' % (expr.valueType.sign, expr.valueType.type)
507507

508508
if expr.variable or isCast(expr):
509+
typeToken = expr.variable.typeStartToken if expr.variable else expr.next
510+
while typeToken and typeToken.isName:
511+
if typeToken.str == 'char' and not typeToken.isSigned and not typeToken.isUnsigned:
512+
return 'char'
513+
typeToken = typeToken.next
509514
if expr.valueType:
510515
if expr.valueType.type == 'bool':
511516
return 'bool'

addons/test/misra/misra-test.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ static void misra_10_3(uint32_t u32a, uint32_t u32b) {
678678
res = (uint16_t)(2U + 3U); // 10.3 10.8
679679
res = (uint16_t)2U + (uint16_t)3U;
680680
res = 0.1f; // 10.3
681+
const char c = '0'; // no-warning
681682
}
682683

683684
static void misra_10_4(u32 x, s32 y) {

0 commit comments

Comments
 (0)