diff --git a/lib/checkother.cpp b/lib/checkother.cpp index 053e419c7..dc9e6012a 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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); } diff --git a/test/testother.cpp b/test/testother.cpp index 7bbf89f9e..1653e712e 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -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() {