MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / misra_10_8

Method misra_10_8

addons/misra.py:2625–2656  ·  view source on GitHub ↗
(self, data)

Source from the content-addressed store, hash-verified

2623 self.reportError(token, 10, 7)
2624
2625 def misra_10_8(self, data):
2626 for token in data.tokenlist:
2627 if not isCast(token):
2628 continue
2629 if not token.valueType or token.valueType.pointer > 0:
2630 continue
2631 if not token.astOperand1.valueType or token.astOperand1.valueType.pointer > 0:
2632 continue
2633 if not token.astOperand1.astOperand1:
2634 continue
2635 if token.astOperand1.str not in ('+', '-', '*', '/', '%', '&', '|', '^', '>>', "<<", "?", ":", '~'):
2636 continue
2637 if token.astOperand1.str != '~' and not token.astOperand1.astOperand2:
2638 continue
2639 if token.astOperand1.str == '~':
2640 e2 = getEssentialTypeCategory(token.astOperand1.astOperand1)
2641 else:
2642 e2, e3 = getEssentialCategorylist(token.astOperand1.astOperand1, token.astOperand1.astOperand2)
2643 if e2 != e3:
2644 continue
2645 e1 = getEssentialTypeCategory(token)
2646 if e1 != e2:
2647 self.reportError(token, 10, 8)
2648 else:
2649 try:
2650 e = getEssentialType(token.astOperand1)
2651 if not e:
2652 continue
2653 if bitsOfEssentialType(token.valueType.type) > bitsOfEssentialType(e):
2654 self.reportError(token, 10, 8)
2655 except ValueError:
2656 pass
2657
2658 def misra_11_1(self, data):
2659 for token in data.tokenlist:

Callers

nothing calls this directly

Calls 6

reportErrorMethod · 0.95
getEssentialTypeCategoryFunction · 0.85
getEssentialCategorylistFunction · 0.85
getEssentialTypeFunction · 0.85
bitsOfEssentialTypeFunction · 0.85
isCastFunction · 0.70

Tested by

no test coverage detected