From 23a53d6d420e74cdd19ae68593e511f52ab62e1a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:27:45 +0200 Subject: [PATCH 1/2] Update tokenize.cpp --- lib/tokenize.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 42cd225d021c49125caac0ec4e4dd5062cddde32 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Wed, 12 Jun 2024 17:29:20 +0200 Subject: [PATCH 2/2] Update testsimplifytypedef.cpp --- test/testsimplifytypedef.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) 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"