...
MSC17-C-EX2: When control flow is intended to cross statement labels, it is permissible to omit the break
statement. In these instances, the unusual control flow must be explicitly documentedmade clear, such as by adding the [[fallthrough]]
C2x attribute, the __attribute__((__fallthrough__))
GNU extension, or a simple comment.
Code Block | ||||
---|---|---|---|---|
| ||||
enum WidgetEnum { WE_W, WE_X, WE_Y, WE_Z } widget_type; widget_type = WE_X; switch (widget_type) { case WE_W: /* ... */ /* No break; processfall through caseto forthe WE_X as wellcase */ case WE_X: /* ... */ break; case WE_Y: case WE_Z: /* ... */ break; default: /* Can't happen */ /* Handle error condition */ } |
...
Tool | Version | Checker | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Astrée |
| switch-clause-break switch-clause-break-continue switch-clause-break-return | Fully checked | ||||||||||||||||
CodeSonar |
| LANG.STRUCT.SW.MB | Missing break | ||||||||||||||||
Compass/ROSE | |||||||||||||||||||
| MISSING_BREAK | Can find instances of missing break statement between cases in | |||||||||||||||||
| CC2.MSC17 | Fully implemented | |||||||||||||||||
Helix QAC |
| C2003 | |||||||||||||||||
Klocwork |
| MISRA.SWITCH.WELL_FORMED.BREAK.2012 | |||||||||||||||||
LDRA tool suite |
| 62 S | Fully implemented | ||||||||||||||||
Parasoft C/C++test |
| JSF-193 | CERT_C-MSC17-a | Missing break statement between cases in a switch statement | |||||||||||||||
PC-lint Plus |
| 616, 825 | Fully supported | ||||||||||||||||
| R2016b |
| CERT C: Rec. MSC17-C | Checks for missing Missing break of switch case | No comments at the end of switch case without a break statement | (rec. fully covered) | |||||||||||||
PVS-StudioPRQA QA-C |
| PRQA QAPRQA QA-C_v | 2003 |
| C_v
|
| V796 | ||||||||||||
RuleChecker |
| switch-clause-break switch-clause-break-continue switch-clause-break-return | Fully checked | ||||||||||||||||
SonarQube C/C++ Plugin |
| NonEmptyCaseWithoutBreak |
...