Skip to content

Commit

Permalink
Fix #12131: No warning for missing override specifier for virtual fun…
Browse files Browse the repository at this point in the history
…ction with different default argument (#5763)

added check for the end off both functions parameter lists during
compare
  • Loading branch information
olabetskyi authored Jan 24, 2024
1 parent a7086c5 commit 88e4f2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/symboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2874,7 +2874,7 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
if (second)
second = second->tokAt(-2);
if (!second) { // End of argument list (second)
return false;
return !first->nextArgument();
}
}

Expand Down
10 changes: 10 additions & 0 deletions test/testclass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8530,6 +8530,16 @@ class TestClass : public TestFixture {
"};\n");
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:8]: (style) The function 'operator->' overrides a function in a base class but is not marked with a 'override' specifier.\n",
errout.str());

checkOverride("class Base {\n" // #12131
" virtual int Calculate(int arg) = 0;\n"
"};\n"
"class Derived : public Base {\n"
" int Calculate(int arg = 0) {\n"
" return arg * 2;\n"
" }\n"
"};\n");
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:5]: (style) The function 'Calculate' overrides a function in a base class but is not marked with a 'override' specifier.\n", errout.str());
}

void overrideCVRefQualifiers() {
Expand Down

0 comments on commit 88e4f2e

Please sign in to comment.