Skip to content

Commit bb5f483

Browse files
Fix #14633 FN funcArgNamesDifferent for function pointer (regression) (danmar#8398)
Co-authored-by: chrchr-github <noreply@github.com>
1 parent 18eb218 commit bb5f483

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

lib/checkother.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4015,8 +4015,6 @@ void CheckOther::checkFuncArgNamesDifferent()
40154015
std::vector<const Token *> definitions(function->argCount());
40164016
const Token * decl = function->argDef->next();
40174017
for (int j = 0; j < function->argCount(); ++j) {
4018-
declarations[j] = nullptr;
4019-
definitions[j] = nullptr;
40204018
// get the definition
40214019
const Variable * variable = function->getArgumentVar(j);
40224020
if (variable) {
@@ -4032,7 +4030,7 @@ void CheckOther::checkFuncArgNamesDifferent()
40324030
break;
40334031
}
40344032
// skip over template
4035-
if (decl->link())
4033+
if (decl->link() && decl->str() == "<")
40364034
decl = decl->link();
40374035
else if (decl->varId())
40384036
declarations[j] = decl;

test/testother.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12754,6 +12754,21 @@ class TestOther : public TestFixture {
1275412754
"[test.cpp:9:20] -> [test.cpp:14:22]: (style, inconclusive) Function 'func4' argument 1 names different: declaration 'a' definition 'A'. [funcArgNamesDifferent]\n"
1275512755
"[test.cpp:9:31] -> [test.cpp:14:29]: (style, inconclusive) Function 'func4' argument 2 names different: declaration 'b' definition 'B'. [funcArgNamesDifferent]\n"
1275612756
"[test.cpp:9:42] -> [test.cpp:14:36]: (style, inconclusive) Function 'func4' argument 3 names different: declaration 'c' definition 'C'. [funcArgNamesDifferent]\n", errout_str());
12757+
12758+
check("using F1 = void (*)();\n" // #14633
12759+
"void f(F1 a);\n"
12760+
"void f(F1 b) {}\n"
12761+
"typedef void (*F2)();\n"
12762+
"void g(F2 a);\n"
12763+
"void g(F2 b) {}\n"
12764+
"void h(void (*a)());\n"
12765+
"void h(void (*b)()) {}\n");
12766+
ASSERT_EQUALS(
12767+
"[test.cpp:2:11] -> [test.cpp:3:11]: (style, inconclusive) Function 'f' argument 1 names different: declaration 'a' definition 'b'. [funcArgNamesDifferent]\n"
12768+
"[test.cpp:5:11] -> [test.cpp:6:11]: (style, inconclusive) Function 'g' argument 1 names different: declaration 'a' definition 'b'. [funcArgNamesDifferent]\n"
12769+
"[test.cpp:7:15] -> [test.cpp:8:15]: (style, inconclusive) Function 'h' argument 1 names different: declaration 'a' definition 'b'. [funcArgNamesDifferent]\n",
12770+
errout_str());
12771+
1275712772
}
1275812773

1275912774
void funcArgOrderDifferent() {

0 commit comments

Comments
 (0)