Menu

#49 Label prevents warning for switch

open
nobody
None
5
2007-07-10
2007-07-10
Anonymous
No

Splint warns when the first statement after a switch is not a case. However, this warning can be blocked by a statement label. In the below fragment we have a warning for the first switch, but not for the second one.

void f( void )
{
int i = 1, c;

switch (i)
{
c = 0;
}

switch (i)
{
lab: c = 2;
}
}

Splint 3.1.1.2 --- 27 May 2007

redef.c: (in function f)
redef.c:10:3: Statement after switch is not a case: c = 0;
The first statement after a switch is not a case. (Use -firstcase to inhibit warning)

Finished checking --- 1 code warning

br
pkzc at freemail dot hu

Discussion


Log in to post a comment.

MongoDB Logo MongoDB