![]() |
![]() |
3234 | ![]() |
||||
![]() | |||||||
| Switch statements | |||||||
The first case label in this switch statement is preceded by one or more declarations. Declarations at the beginning of a switch statement are quite legitimate but are not always encouraged by coding standards. Serious problems only arise if local objects are initialized; the initialization will simply not take place. For example:
/*PRQA S 1-9999 ++*/
/*PRQA S 2008, 2880, 2882, 2961, 3234 --*/
extern int g;
extern int m;
extern int foo(int n)
{
int r;
switch (n) /* Message 2882 */
{
int la; /* Message 3234 */
int lb = 5;
r = 1; /* Message 2008 and 2880 */
case 1:
la = g;
g = m;
m = la;
r = 2;
break;
case 2:
g = lb; /* Message 2961 */
lb = m;
r = 4;
break;
default:
r = 0;
break;
}
return r;
}
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |