Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4043,7 +4043,7 @@ void CheckOtherImpl::checkFuncArgNamesDifferent()
definitions[j] = variable->nameToken();
}
// get the declaration (search for first token with varId)
while (decl && !Token::Match(decl, ",|)|;")) {
while (decl && !Token::Match(decl, "[,;]")) {
// skip everything after the assignment because
// it could also have a varId or be the first
// token with a varId if there is no name token
Expand All @@ -4052,7 +4052,7 @@ void CheckOtherImpl::checkFuncArgNamesDifferent()
break;
}
// skip over templates and arrays
if (decl->link() && decl->str() != "(")
if (decl->link() && !Token::Match(decl, "[()]"))
decl = decl->link();
else if (decl->varId())
declarations[j] = decl;
Expand Down
4 changes: 4 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12955,6 +12955,10 @@ class TestOther : public TestFixture {
"[test.cpp:1:12]: (style, inconclusive) Function 'f' argument 1 names different: declaration 'a' definition '<unnamed>'. [funcArgNamesDifferentUnnamed]\n"
"[test.cpp:4:12]: (style, inconclusive) Function 'g' argument 1 names different: declaration '<unnamed>' definition 'b'. [funcArgNamesDifferentUnnamed]\n",
errout_str());

check("void f(void (*fp)(), int x);\n" // #14847
"void f(void (*fp)(), int x) {}\n");
ASSERT_EQUALS("", errout_str());
}

void funcArgOrderDifferent() {
Expand Down
Loading