(self, data)
| 2418 | self.reportError(token, 10, 1) |
| 2419 | |
| 2420 | def misra_10_2(self, data): |
| 2421 | def isEssentiallySignedOrUnsigned(op): |
| 2422 | e = getEssentialType(op) |
| 2423 | return e and (e.split(' ')[0] in ('unsigned', 'signed')) |
| 2424 | |
| 2425 | def isEssentiallyChar(op): |
| 2426 | if op is None: |
| 2427 | return False |
| 2428 | if op.str == '+': |
| 2429 | return isEssentiallyChar(op.astOperand1) or isEssentiallyChar(op.astOperand2) |
| 2430 | return op.isChar |
| 2431 | |
| 2432 | for token in data.tokenlist: |
| 2433 | if token.str not in ('+', '-'): |
| 2434 | continue |
| 2435 | |
| 2436 | if (not isEssentiallyChar(token.astOperand1)) and (not isEssentiallyChar(token.astOperand2)): |
| 2437 | continue |
| 2438 | |
| 2439 | if token.str == '+': |
| 2440 | if isEssentiallyChar(token.astOperand1) and not isEssentiallySignedOrUnsigned(token.astOperand2): |
| 2441 | self.reportError(token, 10, 2) |
| 2442 | if isEssentiallyChar(token.astOperand2) and not isEssentiallySignedOrUnsigned(token.astOperand1): |
| 2443 | self.reportError(token, 10, 2) |
| 2444 | |
| 2445 | if token.str == '-': |
| 2446 | e1 = getEssentialType(token.astOperand1) |
| 2447 | if e1 and e1.split(' ')[-1] != 'char': |
| 2448 | self.reportError(token, 10, 2) |
| 2449 | if not isEssentiallyChar(token.astOperand2) and not isEssentiallySignedOrUnsigned(token.astOperand2): |
| 2450 | self.reportError(token, 10, 2) |
| 2451 | |
| 2452 | def misra_10_3(self, cfg): |
| 2453 | def get_category(essential_type): |
nothing calls this directly
no test coverage detected