Skip to content

Commit d45d907

Browse files
Fix #14853 FP funcArgNamesDifferentUnnamed with function pointer argument (#8655)
Co-authored-by: chrchr-github <noreply@github.com>
1 parent 3be9d35 commit d45d907

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

lib/checkother.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4052,7 +4052,7 @@ void CheckOtherImpl::checkFuncArgNamesDifferent()
40524052
break;
40534053
}
40544054
// skip over templates and arrays
4055-
if (decl->link() && !Token::Match(decl, "[()]"))
4055+
if (decl->link() && precedes(decl, decl->link()) && !Token::Match(decl, "( [*&]"))
40564056
decl = decl->link();
40574057
else if (decl->varId())
40584058
declarations[j] = decl;

test/testother.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12976,6 +12976,10 @@ class TestOther : public TestFixture {
1297612976
check("void f(void (*fp)(), int x);\n" // #14847
1297712977
"void f(void (*fp)(), int x) {}\n");
1297812978
ASSERT_EQUALS("", errout_str());
12979+
12980+
check("void f(void (*fp)(int a, int b), int b);\n" // #14853
12981+
"void f(void (*fp)(int a, int b), int b) {}\n");
12982+
ASSERT_EQUALS("", errout_str());
1297912983
}
1298012984

1298112985
void funcArgOrderDifferent() {

0 commit comments

Comments
 (0)