[previous] MISRA C:2012  Rule-16.2:  (Required) [next] A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement

Example Code:


#include "misra.h"
#include "m3cmex.h"

extern int16_t rule_1602( void )
{
   int16_t n;

   switch ( s16a )
   {
   case 0:

      if ( s16b == 1 )
      {
         case 1:                /* 2019 */
            break;
      }

      n = get_s16();

      while ( n < 10 )
      {
         ++n;                   /* 2983 */
         case 2:
            break;
      }
   default:                     /* 2003 */
      break;
   }

   return 1;
}


QAC messages that encompass this guideline:

2019 'Switch' label is located within a nested code block.



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