Fixed #4234 (segmentation fault of cppcheck in Tokenizer::simplifyFlowControl() (invalid code))

This commit is contained in:
Edoardo Prezioso 2012-10-06 13:37:44 +02:00
parent c2b61030a8
commit e3bbcf501f
2 changed files with 4 additions and 1 deletions

View File

@ -2400,7 +2400,7 @@ void Tokenizer::simplifyLabelsCaseDefault()
if (Token::Match(tok, "[;{}] case")) {
while (NULL != (tok = tok->next())) {
if (tok->str() == ":")
if (Token::Match(tok,"[:{};]"))
break;
}
if (!tok)

View File

@ -5716,6 +5716,9 @@ private:
//ticket #3227
ASSERT_EQUALS("void foo ( ) { switch ( n ) { label : ; case 1 : ; label1 : ; label2 : ; break ; } }",
tokenizeAndStringify("void foo(){ switch (n){ label: case 1: label1: label2: break; }}"));
//ticket #4234
ASSERT_EQUALS("( ) { switch break ; { switch ( x ) { case } y break ; : } }",
tokenizeAndStringify("( ) { switch break ; { switch ( x ) { case } y break ; : } }"));
}
void simplifyPointerToStandardType() {