Skip to content

Commit a6c98e9

Browse files
committed
Fixed #10482 (FP: misra-c2012-12.2)
1 parent b6abe9c commit a6c98e9

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

.github/workflows/CI-unixish.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ jobs:
146146
./cppcheck --addon=misra --inline-suppr --enable=information --error-exitcode=1 addons/test/misra/misra-ctu-*-test.c
147147
cd addons/test
148148
../../cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test.c --std=c89 --platform=unix64 && python3 ../misra.py -verify misra/misra-test.c.dump
149+
../../cppcheck --addon=misra --platform=avr8 --error-exitcode=1 misra/misra-test-avr8.c
149150
150151
- name: Build GUI on ubuntu
151152
if: contains(matrix.os, 'ubuntu')

addons/misra.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -568,19 +568,19 @@ def getEssentialType(expr):
568568
def bitsOfEssentialType(ty):
569569
if ty is None:
570570
return 0
571-
ty = ty.split(' ')[-1]
572-
if ty == 'Boolean':
571+
last_type = ty.split(' ')[-1]
572+
if last_type == 'Boolean':
573573
return 1
574-
if ty == 'char':
574+
if last_type == 'char':
575575
return typeBits['CHAR']
576-
if ty == 'short':
576+
if last_type == 'short':
577577
return typeBits['SHORT']
578-
if ty == 'int':
578+
if last_type == 'int':
579579
return typeBits['INT']
580-
if ty == 'long':
581-
return typeBits['LONG']
582-
if ty == 'long long':
580+
if ty.endswith('long long'):
583581
return typeBits['LONG_LONG']
582+
if last_type == 'long':
583+
return typeBits['LONG']
584584
for sty in STDINT_TYPES:
585585
if ty == sty:
586586
return int(''.join(filter(str.isdigit, sty)))
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// To test:
2+
// ~/cppcheck/cppcheck --addon=misra --platform=avr8 misra-test-avr8.c
3+
4+
static void misra_12_2(void) {
5+
a = (((uint64_t)0xFF) << 32);
6+
}
7+

0 commit comments

Comments
 (0)