Fixed #10397 (FP constParameter - implementing an interface)

This commit is contained in:
Daniel Marjamäki 2021-08-10 15:37:59 +02:00
parent c2305b1da7
commit e95395e5f0
2 changed files with 8 additions and 0 deletions

View File

@ -1501,6 +1501,10 @@ void CheckOther::checkConstPointer()
nonConstPointers.insert(tok->variable());
}
for (const Variable *p: pointers) {
if (p->isArgument()) {
if (!p->scope() || !p->scope()->function || p->scope()->function->isImplicitlyVirtual(true) || p->scope()->function->hasVirtualSpecifier())
continue;
}
if (nonConstPointers.find(p) == nonConstPointers.end())
constVariableError(p, nullptr);
}

View File

@ -2746,6 +2746,10 @@ private:
" w = 1;\n"
"}");
ASSERT_EQUALS("", errout.str());
check("class Base { virtual void dostuff(int *p) = 0; };\n" // #10397
"class Derived: public Base { int x; void dostuff(int *p) override { x = *p; } };");
ASSERT_EQUALS("", errout.str());
}
void switchRedundantAssignmentTest() {