[previous] MISRA C:2012  Rule-15.3:  (Required) [next] Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement

Amplification:

For the purposes of this rule, a switch-clause that does not consist of a compound statement is treated as if it were a block.

Example Code:


#pragma PRQA_MESSAGES_OFF 2981

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


extern int16_t rule_1503( void )
{
   if (s16a > 10) {
      goto LAB1;                                      /* 2001           */
   }

   if (s16a > 5) {
      SI     z = 5;

      LAB1:                                           /*      3311      */
      z = 1;
      s16b = s16b + z;
   }

   return 1;
}


QAC messages that encompass this guideline:

3311 [u] An earlier jump to this statement will bypass the initialization of local variables.


Related rules:

Rule-1.3 There shall be no occurrence of undefined or critical unspecified behaviour



(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