(self, cfg)
| 2526 | self.reportError(token, 10, 4) |
| 2527 | |
| 2528 | def misra_10_5(self, cfg): |
| 2529 | def _get_essential_category(token): |
| 2530 | essential_type = getEssentialType(token) |
| 2531 | #print(essential_type) |
| 2532 | if essential_type: |
| 2533 | if essential_type in ('bool', 'char'): |
| 2534 | return essential_type |
| 2535 | if essential_type.split(' ')[-1] in ('float', 'double'): |
| 2536 | return 'floating' |
| 2537 | if essential_type.split(' ')[0] in ('unsigned', 'signed'): |
| 2538 | return essential_type.split(' ')[0] |
| 2539 | return None |
| 2540 | for token in cfg.tokenlist: |
| 2541 | if not isCast(token): |
| 2542 | continue |
| 2543 | to_type = _get_essential_category(token) |
| 2544 | #print(to_type) |
| 2545 | if to_type is None: |
| 2546 | continue |
| 2547 | from_type = _get_essential_category(token.astOperand1) |
| 2548 | #print(from_type) |
| 2549 | if from_type is None: |
| 2550 | continue |
| 2551 | if to_type == from_type: |
| 2552 | continue |
| 2553 | if to_type == 'bool' or from_type == 'bool': |
| 2554 | if token.astOperand1.isInt and token.astOperand1.getKnownIntValue() == 1: |
| 2555 | # Exception |
| 2556 | continue |
| 2557 | self.reportError(token, 10, 5) |
| 2558 | continue |
| 2559 | if to_type == 'enum': |
| 2560 | self.reportError(token, 10, 5) |
| 2561 | continue |
| 2562 | if from_type == 'float' and to_type == 'char': |
| 2563 | self.reportError(token, 10, 5) |
| 2564 | continue |
| 2565 | if from_type == 'char' and to_type == 'float': |
| 2566 | self.reportError(token, 10, 5) |
| 2567 | continue |
| 2568 | |
| 2569 | def misra_10_6(self, data): |
| 2570 | for token in data.tokenlist: |
nothing calls this directly
no test coverage detected