Skip to content

Commit 88e4f2e

Browse files
authored
Fix #12131: No warning for missing override specifier for virtual function with different default argument (#5763)
added check for the end off both functions parameter lists during compare
1 parent a7086c5 commit 88e4f2e

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

lib/symboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2874,7 +2874,7 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
28742874
if (second)
28752875
second = second->tokAt(-2);
28762876
if (!second) { // End of argument list (second)
2877-
return false;
2877+
return !first->nextArgument();
28782878
}
28792879
}
28802880

test/testclass.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8530,6 +8530,16 @@ class TestClass : public TestFixture {
85308530
"};\n");
85318531
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",
85328532
errout.str());
8533+
8534+
checkOverride("class Base {\n" // #12131
8535+
" virtual int Calculate(int arg) = 0;\n"
8536+
"};\n"
8537+
"class Derived : public Base {\n"
8538+
" int Calculate(int arg = 0) {\n"
8539+
" return arg * 2;\n"
8540+
" }\n"
8541+
"};\n");
8542+
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());
85338543
}
85348544

85358545
void overrideCVRefQualifiers() {

0 commit comments

Comments
 (0)