Start here

Home
About Klocwork
What's new
Fixed issues
Release notes
Installation

Reference

C/C++ checkers
Java checkers
C# checkers
MISRA C 2004 checkers
MISRA C++ 2008 checkers
MISRA C 2012 checkers
MISRA C 2012 checkers with Amendment 1
Commands
Metrics
Troubleshooting
Reference

Product components

C/C++ Integration build analysis
Java Integration build analysis
Desktop analysis
Refactoring
Klocwork Static Code Analysis
Klocwork Code Review
Structure101
Tuning
Custom checkers

Coding environments

Visual Studio
Eclipse for C/C++
Eclipse for Java
IntelliJ IDEA
Other

Administration

Project configuration
Build configuration
Administration
Analysis performance
Server performance
Security/permissions
Licensing
Klocwork Static Code Analysis Web API
Klocwork Code Review Web API

Community

View help online
Visit RogueWave.com
Klocwork Support
Rogue Wave Videos

Legal

Legal information

MISRA.SWITCH.NO_CASE

No case-clause in a switch statement.

MISRA-C Rule 15.5 (required): Every switch statement shall have at least one case clause.

Example

switch (x)
{
   uint8_t var;     /* not compliant - decl before 1st case     */
case 0:
   a = b;
   break;           /* break is required here                   */
case 1:             /* empty clause, break not required         */
case 2:
   a = c;           /* executed if x is 1 or 2                  */
   if ( a == b )
   {
      case 3:       /* Not compliant - case is not allowed here */
   }
   break;           /* break is required here                   */
case 4:
   a = b;           /* Not compliant - non empty drop through   */
case 5:
   a = c;
   break;
default:            /* default clause is required               */
   errorflag = 1;   /* should be non-empty if possible          */
   break;           /* break is required here, in case a
                       future modification turns this into a
                       case clause                              */
}

MISRA-C++ Rule 6-4-8 (required): Every switch statement shall have at least one case-clause.

Rationale

A switch statement with no case-clauses is redundant.

Example

switch ( x )
{
              // Non-compliant
default:
   break;
}