Fixed #10480 (FP: misra-c2012-10.4 (char))
This commit is contained in:
parent
255dc0484a
commit
4ad09f181a
|
@ -443,8 +443,11 @@ def getEssentialTypeCategory(expr):
|
|||
return expr.valueType.sign
|
||||
if expr.valueType and expr.valueType.typeScope and expr.valueType.typeScope.className:
|
||||
return "enum<" + expr.valueType.typeScope.className + ">"
|
||||
if expr.variable:
|
||||
typeToken = expr.variable.typeStartToken
|
||||
vartok = expr
|
||||
while simpleMatch(vartok, '[') or (vartok and vartok.str == '*' and vartok.astOperand2 is None):
|
||||
vartok = vartok.astOperand1
|
||||
if vartok and vartok.variable:
|
||||
typeToken = vartok.variable.typeStartToken
|
||||
while typeToken and typeToken.isName:
|
||||
if typeToken.str == 'char' and not typeToken.isSigned and not typeToken.isUnsigned:
|
||||
return 'char'
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
// To test:
|
||||
// ~/cppcheck/cppcheck --addon=misra --platform=avr8 misra-test-avr8.c
|
||||
|
||||
static void misra_10_4(void)
|
||||
{
|
||||
// #10480
|
||||
char buf[1] = {'f'};
|
||||
const char c = '0';
|
||||
signed int x = buf[0] - c;
|
||||
}
|
||||
|
||||
static void misra_12_2(void) {
|
||||
a = (((uint64_t)0xFF) << 32);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue