diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 698ef62e78b..13ad6d29577 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -4015,8 +4015,6 @@ void CheckOther::checkFuncArgNamesDifferent() std::vector definitions(function->argCount()); const Token * decl = function->argDef->next(); for (int j = 0; j < function->argCount(); ++j) { - declarations[j] = nullptr; - definitions[j] = nullptr; // get the definition const Variable * variable = function->getArgumentVar(j); if (variable) { @@ -4032,7 +4030,7 @@ void CheckOther::checkFuncArgNamesDifferent() break; } // skip over template - if (decl->link()) + if (decl->link() && decl->str() == "<") decl = decl->link(); else if (decl->varId()) declarations[j] = decl; diff --git a/test/testother.cpp b/test/testother.cpp index 0c6828a0b63..c6788a16f3a 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -12754,6 +12754,21 @@ class TestOther : public TestFixture { "[test.cpp:9:20] -> [test.cpp:14:22]: (style, inconclusive) Function 'func4' argument 1 names different: declaration 'a' definition 'A'. [funcArgNamesDifferent]\n" "[test.cpp:9:31] -> [test.cpp:14:29]: (style, inconclusive) Function 'func4' argument 2 names different: declaration 'b' definition 'B'. [funcArgNamesDifferent]\n" "[test.cpp:9:42] -> [test.cpp:14:36]: (style, inconclusive) Function 'func4' argument 3 names different: declaration 'c' definition 'C'. [funcArgNamesDifferent]\n", errout_str()); + + check("using F1 = void (*)();\n" // #14633 + "void f(F1 a);\n" + "void f(F1 b) {}\n" + "typedef void (*F2)();\n" + "void g(F2 a);\n" + "void g(F2 b) {}\n" + "void h(void (*a)());\n" + "void h(void (*b)()) {}\n"); + ASSERT_EQUALS( + "[test.cpp:2:11] -> [test.cpp:3:11]: (style, inconclusive) Function 'f' argument 1 names different: declaration 'a' definition 'b'. [funcArgNamesDifferent]\n" + "[test.cpp:5:11] -> [test.cpp:6:11]: (style, inconclusive) Function 'g' argument 1 names different: declaration 'a' definition 'b'. [funcArgNamesDifferent]\n" + "[test.cpp:7:15] -> [test.cpp:8:15]: (style, inconclusive) Function 'h' argument 1 names different: declaration 'a' definition 'b'. [funcArgNamesDifferent]\n", + errout_str()); + } void funcArgOrderDifferent() {