Skip to content

Commit

Permalink
Fix #12808 FP passedByValue for struct parameter in extern "C" functi…
Browse files Browse the repository at this point in the history
…on (#6516)
  • Loading branch information
chrchr-github authored Jun 13, 2024
1 parent 5ef9ba0 commit c71caef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions test/testsimplifytypedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit c71caef

Please sign in to comment.