![]() |
|
MISRA-C:2004 Rule 15.0: (Required) |
|
||||
![]() | |||||||
The following syntax rules are additional to the C standard syntax rules. All syntax rules not defined below are as defined in the C standard.
switch-statement:
case-label-clause-list:
case-label:
case-clause:
default-label-clause:
default-label:
default-clause:
and
statement:
The following terms are also used within the text of the rules:
| switch label | Either a case label or default label. |
| case clause | The code between any two switch labels. |
| default clause | The code between the default label and the end of the switch statement. |
| switch clause | Either a case clause or a default clause. |
Example Code:
#include "misra.h"
#include "m2cmex.h"
extern S16 test_1500( void )
{
switch ( s16a )
{
static S16 s16x1500; /* MISRA Violation */
case 1:
s16x1500 = s16a;
break;
case 2:
s16b = s16x1500;
break;
default:
break;
}
return 1;
}
QAC messages that encompass this guideline:
| 3234 | Declarations precede the first label in this 'switch' construct. |
|
||
(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 |