parent
8179226b18
commit
d64dadcd31
|
@ -2169,7 +2169,7 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, bool&
|
|||
if (var && var->isStlType(stl_containers_not_const))
|
||||
return false;
|
||||
const Token* assignTok = end->next()->astParent();
|
||||
if (assignTok && assignTok->isAssignmentOp() && assignTok->astOperand1() && assignTok->astOperand1()->variable()) {
|
||||
if (var && assignTok && assignTok->isAssignmentOp() && assignTok->astOperand1() && assignTok->astOperand1()->variable()) {
|
||||
const Variable* assignVar = assignTok->astOperand1()->variable();
|
||||
if (assignVar->isPointer() && !assignVar->isConst() && var->typeScope()) {
|
||||
const auto& funcMap = var->typeScope()->functionMap;
|
||||
|
|
|
@ -5900,6 +5900,15 @@ private:
|
|||
" }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkConst("struct S {\n" // #10758
|
||||
" T* h;\n"
|
||||
" void f(); \n"
|
||||
"};\n"
|
||||
"void S::f() {\n"
|
||||
" char* c = h->x[y];\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (style, inconclusive) Technically the member function 'S::f' can be const.\n", errout.str());
|
||||
}
|
||||
|
||||
void const_handleDefaultParameters() {
|
||||
|
|
Loading…
Reference in New Issue