Fixed #10499 (FP: misra-c2012-10.4)

This commit is contained in:
Daniel Marjamäki 2021-09-23 10:44:38 +02:00
parent 2e682b1bf3
commit 3c1ae77962
2 changed files with 15 additions and 2 deletions

View File

@ -459,6 +459,13 @@ def getEssentialTypeCategory(expr):
if typeToken.valueType.sign:
return typeToken.valueType.sign
typeToken = typeToken.next
# See Appendix D, section D.6, Character constants
if expr.str[0] == "'" and expr.str[-1] == "'":
if len(expr.str) == 3 or (len(expr.str) == 4 and expr.str[1] == '\\'):
return 'char'
return expr.valueType.sign
if expr.valueType:
return expr.valueType.sign
return None

View File

@ -669,13 +669,13 @@ static void misra_10_2(void) {
float f32a = 0.0;
char res;
res = '0' + u8a; // 10.4
res = '0' + u8a; // Convert u8a to digit
res = s8a + '0';
res = cha - '0';
res = '0' - s8a;
res = cha + ':'; // 10.2
res = s16a - 'a'; // 10.2 10.3
res = s16a - 'a'; // 10.2 10.3 10.4
res = '0' + f32a; // 10.2 10.4
}
@ -699,6 +699,12 @@ static void misra_10_4(u32 x, s32 y) {
z = x + y; //10.4
z = (a == misra_10_4_A3) ? x : y; //10.4
z = (a == misra_10_4_A3) ? y : y; // no-warning
// #10499
const char buf[10] = {0};
if ('0' == buf[x]) // no-warning
{
}
}
static void misra_10_5(uint16_t x) {