[previous] MISRA-C:2004  Rule  15.2:  (Required) [next] An unconditional break statement shall terminate every non-empty switch clause.
The last statement in every switch clause shall be a break statement, or if the switch clause is a compound statement, then the last statement in the compound statement shall be a break statement.

Example Code:


#include "misra.h"
#include "m2cmex.h"


extern S16 test_1502( void )
{
   switch ( s16a )
   {
   case 0:

   case 1:
      ++s16b;
      break;

   case 2:
      ++s16c;

   case 3:              /* MISRA Violation */
      ++s16b;

   default:             /* MISRA Violation */
      ++s16c;
   }                    /* MISRA Violation */

   return 1;
}


QAC messages that encompass this guideline:

2003 The preceding 'switch' clause is not empty and does not end with a 'jump' statement. Execution will fall through.
2020 Final 'switch' clause does not end with an explicit 'jump' statement.



(c) The Motor Industry Research Association, 2004
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents