diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index ba80dc095c0..aeb02c0ea81 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -1794,7 +1794,7 @@ void Tokenizer::simplifyTypedefCpp() } // check for typedef that can be substituted - else if ((tok2->isNameOnly() || (tok2->isName() && (tok2->isExpandedMacro() || tok2->isInline()))) && + else if ((tok2->isNameOnly() || (tok2->isName() && (tok2->isExpandedMacro() || tok2->isInline() || tok2->isExternC()))) && (Token::simpleMatch(tok2, pattern.c_str(), pattern.size()) || (inMemberFunc && tok2->str() == typeName->str()))) { // member function class variables don't need qualification diff --git a/test/testsimplifytypedef.cpp b/test/testsimplifytypedef.cpp index 6809a7d275d..ab4a32b8f26 100644 --- a/test/testsimplifytypedef.cpp +++ b/test/testsimplifytypedef.cpp @@ -219,6 +219,7 @@ class TestSimplifyTypedef : public TestFixture { TEST_CASE(simplifyTypedef152); TEST_CASE(simplifyTypedef153); TEST_CASE(simplifyTypedef154); + TEST_CASE(simplifyTypedef155); TEST_CASE(simplifyTypedefFunction1); TEST_CASE(simplifyTypedefFunction2); // ticket #1685 @@ -3614,6 +3615,15 @@ class TestSimplifyTypedef : public TestFixture { ASSERT_EQUALS(exp, tok(code)); } + void simplifyTypedef155() { + const char code[] = "typedef struct S T;\n" // #12808 + "typedef struct S { int i; } T;\n" + "extern \"C\" void f(T* t);\n"; + const char exp[] = "struct S { int i ; } ; " + "void f ( struct S * t ) ;"; + ASSERT_EQUALS(exp, tok(code)); + } + void simplifyTypedefFunction1() { { const char code[] = "typedef void (*my_func)();\n"