Fixed #7030 (Tokenizer::simplifyTypedef: Label)

This commit is contained in:
Daniel Marjamäki 2015-10-15 16:56:22 +02:00
parent 430e31ec1e
commit 6cf25825de
2 changed files with 9 additions and 1 deletions

View File

@ -1187,7 +1187,7 @@ void Tokenizer::simplifyTypedef()
tok2->tokAt(-3)->deleteNext(2);
simplifyType = true;
}
} else if (Token::Match(tok2->previous(), "case %type% :")) {
} else if (Token::Match(tok2->previous(), "case|;|{|} %type% :")) {
tok2 = tok2->next();
} else if (duplicateTypedef(&tok2, typeName, typeDef, structs)) {
// skip to end of scope if not already there

View File

@ -149,6 +149,7 @@ private:
TEST_CASE(simplifyTypedef110); // ticket #6268
TEST_CASE(simplifyTypedef111); // ticket #6345
TEST_CASE(simplifyTypedef112); // ticket #6048
TEST_CASE(simplifyTypedef113); // ticket #7030
TEST_CASE(simplifyTypedefFunction1);
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@ -2406,6 +2407,13 @@ private:
ASSERT_EQUALS("", errout.str());
}
void simplifyTypedef113() { // ticket #7030
const char code[] = "typedef int T;\n"
"void f() { T:; }";
const char expected[] = "void f ( ) { T : ; }";
ASSERT_EQUALS(expected, tok(code));
}
void simplifyTypedefFunction1() {
{
const char code[] = "typedef void (*my_func)();\n"