Skip to content

Commit e95395e

Browse files
committed
Fixed #10397 (FP constParameter - implementing an interface)
1 parent c2305b1 commit e95395e

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

lib/checkother.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,10 @@ void CheckOther::checkConstPointer()
15011501
nonConstPointers.insert(tok->variable());
15021502
}
15031503
for (const Variable *p: pointers) {
1504+
if (p->isArgument()) {
1505+
if (!p->scope() || !p->scope()->function || p->scope()->function->isImplicitlyVirtual(true) || p->scope()->function->hasVirtualSpecifier())
1506+
continue;
1507+
}
15041508
if (nonConstPointers.find(p) == nonConstPointers.end())
15051509
constVariableError(p, nullptr);
15061510
}

test/testother.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,6 +2746,10 @@ class TestOther : public TestFixture {
27462746
" w = 1;\n"
27472747
"}");
27482748
ASSERT_EQUALS("", errout.str());
2749+
2750+
check("class Base { virtual void dostuff(int *p) = 0; };\n" // #10397
2751+
"class Derived: public Base { int x; void dostuff(int *p) override { x = *p; } };");
2752+
ASSERT_EQUALS("", errout.str());
27492753
}
27502754

27512755
void switchRedundantAssignmentTest() {

0 commit comments

Comments
 (0)