diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 801dc529568..551c3a47543 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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 @@ -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; diff --git a/test/testother.cpp b/test/testother.cpp index 73f10cbe76e..c8a95c9882b 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -12955,6 +12955,10 @@ class TestOther : public TestFixture { "[test.cpp:1:12]: (style, inconclusive) Function 'f' argument 1 names different: declaration 'a' definition ''. [funcArgNamesDifferentUnnamed]\n" "[test.cpp:4:12]: (style, inconclusive) Function 'g' argument 1 names different: declaration '' 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() {