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

Method misra_11_8

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

Source from the content-addressed store, hash-verified

2808 self.reportError(token, 11, 7)
2809
2810 def misra_11_8(self, data):
2811 # TODO: reuse code in CERT-EXP05
2812 for token in data.tokenlist:
2813 if isCast(token):
2814 # C-style cast
2815 if not token.valueType:
2816 continue
2817 if not token.astOperand1.valueType:
2818 continue
2819 if token.valueType.pointer == 0:
2820 continue
2821 if token.astOperand1.valueType.pointer == 0:
2822 continue
2823 const1 = token.valueType.constness
2824 const2 = token.astOperand1.valueType.constness
2825 if (const1 % 2) < (const2 % 2):
2826 self.reportError(token, 11, 8)
2827
2828 elif token.str == '(' and token.astOperand1 and token.astOperand2 and token.astOperand1.function:
2829 # Function call
2830 function = token.astOperand1.function
2831 arguments = getArguments(token)
2832 for argnr, argvar in function.argument.items():
2833 if argnr < 1 or argnr > len(arguments):
2834 continue
2835 if not argvar.isPointer:
2836 continue
2837 argtok = arguments[argnr - 1]
2838 if not argtok.valueType:
2839 continue
2840 if argtok.valueType.pointer == 0:
2841 continue
2842 const1 = argvar.constness
2843 const2 = arguments[argnr - 1].valueType.constness
2844 if (const1 % 2) < (const2 % 2):
2845 self.reportError(token, 11, 8)
2846
2847 def misra_11_9(self, data):
2848 for token in data.tokenlist:

Callers

nothing calls this directly

Calls 3

reportErrorMethod · 0.95
isCastFunction · 0.70
getArgumentsFunction · 0.70

Tested by

no test coverage detected