Skip to content

Commit 6cf2582

Browse files
committed
Fixed danmar#7030 (Tokenizer::simplifyTypedef: Label)
1 parent 430e31e commit 6cf2582

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/tokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,7 @@ void Tokenizer::simplifyTypedef()
11871187
tok2->tokAt(-3)->deleteNext(2);
11881188
simplifyType = true;
11891189
}
1190-
} else if (Token::Match(tok2->previous(), "case %type% :")) {
1190+
} else if (Token::Match(tok2->previous(), "case|;|{|} %type% :")) {
11911191
tok2 = tok2->next();
11921192
} else if (duplicateTypedef(&tok2, typeName, typeDef, structs)) {
11931193
// skip to end of scope if not already there

test/testsimplifytypedef.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class TestSimplifyTypedef : public TestFixture {
149149
TEST_CASE(simplifyTypedef110); // ticket #6268
150150
TEST_CASE(simplifyTypedef111); // ticket #6345
151151
TEST_CASE(simplifyTypedef112); // ticket #6048
152+
TEST_CASE(simplifyTypedef113); // ticket #7030
152153

153154
TEST_CASE(simplifyTypedefFunction1);
154155
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@@ -2406,6 +2407,13 @@ class TestSimplifyTypedef : public TestFixture {
24062407
ASSERT_EQUALS("", errout.str());
24072408
}
24082409

2410+
void simplifyTypedef113() { // ticket #7030
2411+
const char code[] = "typedef int T;\n"
2412+
"void f() { T:; }";
2413+
const char expected[] = "void f ( ) { T : ; }";
2414+
ASSERT_EQUALS(expected, tok(code));
2415+
}
2416+
24092417
void simplifyTypedefFunction1() {
24102418
{
24112419
const char code[] = "typedef void (*my_func)();\n"

0 commit comments

Comments
 (0)