Fixed #10481 (misra.py: Bailing out from checking test.c since there was an internal error: Failed to ...)

This commit is contained in:
Daniel Marjamäki 2021-09-25 21:53:55 +02:00
parent 5767ba794a
commit 2a64ad8dbb
2 changed files with 6 additions and 1 deletions

View File

@ -2150,7 +2150,8 @@ class MisraChecker:
self.reportError(token, 10, 2)
if token.str == '-':
if getEssentialType(token.astOperand1).split(' ')[-1] != 'char':
e1 = getEssentialType(token.astOperand1)
if e1 and e1.split(' ')[-1] != 'char':
self.reportError(token, 10, 2)
if not isEssentiallyChar(token.astOperand2) and not isEssentiallySignedOrUnsigned(token.astOperand2):
self.reportError(token, 10, 2)

View File

@ -677,6 +677,10 @@ static void misra_10_2(void) {
res = s16a - 'a'; // 10.2 10.3 10.4
res = '0' + f32a; // 10.2 10.4
// 10481 - crash
char buf[1] = {'f'};
x = buf[0] - '0';
}
static void misra_10_3(uint32_t u32a, uint32_t u32b) {