Fixed #10482 (FP: misra-c2012-12.2)

This commit is contained in:
Daniel Marjamäki 2021-09-17 14:21:25 +02:00
parent b6abe9c5fe
commit a6c98e9e60
3 changed files with 16 additions and 8 deletions

View File

@ -146,6 +146,7 @@ jobs:
./cppcheck --addon=misra --inline-suppr --enable=information --error-exitcode=1 addons/test/misra/misra-ctu-*-test.c ./cppcheck --addon=misra --inline-suppr --enable=information --error-exitcode=1 addons/test/misra/misra-ctu-*-test.c
cd addons/test cd addons/test
../../cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test.c --std=c89 --platform=unix64 && python3 ../misra.py -verify misra/misra-test.c.dump ../../cppcheck --dump -DDUMMY --suppress=uninitvar --inline-suppr misra/misra-test.c --std=c89 --platform=unix64 && python3 ../misra.py -verify misra/misra-test.c.dump
../../cppcheck --addon=misra --platform=avr8 --error-exitcode=1 misra/misra-test-avr8.c
- name: Build GUI on ubuntu - name: Build GUI on ubuntu
if: contains(matrix.os, 'ubuntu') if: contains(matrix.os, 'ubuntu')

View File

@ -568,19 +568,19 @@ def getEssentialType(expr):
def bitsOfEssentialType(ty): def bitsOfEssentialType(ty):
if ty is None: if ty is None:
return 0 return 0
ty = ty.split(' ')[-1] last_type = ty.split(' ')[-1]
if ty == 'Boolean': if last_type == 'Boolean':
return 1 return 1
if ty == 'char': if last_type == 'char':
return typeBits['CHAR'] return typeBits['CHAR']
if ty == 'short': if last_type == 'short':
return typeBits['SHORT'] return typeBits['SHORT']
if ty == 'int': if last_type == 'int':
return typeBits['INT'] return typeBits['INT']
if ty == 'long': if ty.endswith('long long'):
return typeBits['LONG']
if ty == 'long long':
return typeBits['LONG_LONG'] return typeBits['LONG_LONG']
if last_type == 'long':
return typeBits['LONG']
for sty in STDINT_TYPES: for sty in STDINT_TYPES:
if ty == sty: if ty == sty:
return int(''.join(filter(str.isdigit, sty))) return int(''.join(filter(str.isdigit, sty)))

View File

@ -0,0 +1,7 @@
// To test:
// ~/cppcheck/cppcheck --addon=misra --platform=avr8 misra-test-avr8.c
static void misra_12_2(void) {
a = (((uint64_t)0xFF) << 32);
}