Skip to content

Commit c71caef

Browse files
Fix #12808 FP passedByValue for struct parameter in extern "C" function (#6516)
1 parent 5ef9ba0 commit c71caef

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/tokenize.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1794,7 +1794,7 @@ void Tokenizer::simplifyTypedefCpp()
17941794
}
17951795

17961796
// check for typedef that can be substituted
1797-
else if ((tok2->isNameOnly() || (tok2->isName() && (tok2->isExpandedMacro() || tok2->isInline()))) &&
1797+
else if ((tok2->isNameOnly() || (tok2->isName() && (tok2->isExpandedMacro() || tok2->isInline() || tok2->isExternC()))) &&
17981798
(Token::simpleMatch(tok2, pattern.c_str(), pattern.size()) ||
17991799
(inMemberFunc && tok2->str() == typeName->str()))) {
18001800
// member function class variables don't need qualification

test/testsimplifytypedef.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ class TestSimplifyTypedef : public TestFixture {
219219
TEST_CASE(simplifyTypedef152);
220220
TEST_CASE(simplifyTypedef153);
221221
TEST_CASE(simplifyTypedef154);
222+
TEST_CASE(simplifyTypedef155);
222223

223224
TEST_CASE(simplifyTypedefFunction1);
224225
TEST_CASE(simplifyTypedefFunction2); // ticket #1685
@@ -3614,6 +3615,15 @@ class TestSimplifyTypedef : public TestFixture {
36143615
ASSERT_EQUALS(exp, tok(code));
36153616
}
36163617

3618+
void simplifyTypedef155() {
3619+
const char code[] = "typedef struct S T;\n" // #12808
3620+
"typedef struct S { int i; } T;\n"
3621+
"extern \"C\" void f(T* t);\n";
3622+
const char exp[] = "struct S { int i ; } ; "
3623+
"void f ( struct S * t ) ;";
3624+
ASSERT_EQUALS(exp, tok(code));
3625+
}
3626+
36173627
void simplifyTypedefFunction1() {
36183628
{
36193629
const char code[] = "typedef void (*my_func)();\n"

0 commit comments

Comments
 (0)