Skip to content
Merged
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: 1 addition & 3 deletions lib/checkother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4015,8 +4015,6 @@ void CheckOther::checkFuncArgNamesDifferent()
std::vector<const Token *> 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) {
Expand All @@ -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;
Expand Down
15 changes: 15 additions & 0 deletions test/testother.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading