Skip to content

Commit 2a64ad8

Browse files
committed
Fixed #10481 (misra.py: Bailing out from checking test.c since there was an internal error: Failed to ...)
1 parent 5767ba7 commit 2a64ad8

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

addons/misra.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2150,7 +2150,8 @@ def isEssentiallyChar(op):
21502150
self.reportError(token, 10, 2)
21512151

21522152
if token.str == '-':
2153-
if getEssentialType(token.astOperand1).split(' ')[-1] != 'char':
2153+
e1 = getEssentialType(token.astOperand1)
2154+
if e1 and e1.split(' ')[-1] != 'char':
21542155
self.reportError(token, 10, 2)
21552156
if not isEssentiallyChar(token.astOperand2) and not isEssentiallySignedOrUnsigned(token.astOperand2):
21562157
self.reportError(token, 10, 2)

addons/test/misra/misra-test.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,10 @@ static void misra_10_2(void) {
677677

678678
res = s16a - 'a'; // 10.2 10.3 10.4
679679
res = '0' + f32a; // 10.2 10.4
680+
681+
// 10481 - crash
682+
char buf[1] = {'f'};
683+
x = buf[0] - '0';
680684
}
681685

682686
static void misra_10_3(uint32_t u32a, uint32_t u32b) {

0 commit comments

Comments
 (0)