parent
8f432880fa
commit
30bf5cac0a
|
@ -2531,8 +2531,10 @@ bool CheckClass::checkConstFunc(const Scope *scope, const Function *func, Member
|
||||||
;
|
;
|
||||||
} else if (hasOverloadedMemberAccess(end, var->typeScope())) {
|
} else if (hasOverloadedMemberAccess(end, var->typeScope())) {
|
||||||
;
|
;
|
||||||
} else if (!var->typeScope() || (end->function() != func && !isConstMemberFunc(var->typeScope(), end)))
|
} else if (!var->typeScope() || (end->function() != func && !isConstMemberFunc(var->typeScope(), end))) {
|
||||||
return false;
|
if (!mSettings->library.isFunctionConst(end))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assignment
|
// Assignment
|
||||||
|
|
|
@ -181,6 +181,7 @@ private:
|
||||||
TEST_CASE(const90);
|
TEST_CASE(const90);
|
||||||
TEST_CASE(const91);
|
TEST_CASE(const91);
|
||||||
TEST_CASE(const92);
|
TEST_CASE(const92);
|
||||||
|
TEST_CASE(const93);
|
||||||
|
|
||||||
TEST_CASE(const_handleDefaultParameters);
|
TEST_CASE(const_handleDefaultParameters);
|
||||||
TEST_CASE(const_passThisToMemberOfOtherClass);
|
TEST_CASE(const_passThisToMemberOfOtherClass);
|
||||||
|
@ -6666,6 +6667,21 @@ private:
|
||||||
// don't hang
|
// don't hang
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void const93() { // #12162
|
||||||
|
checkConst("struct S {\n"
|
||||||
|
" bool f() {\n"
|
||||||
|
" return m.cbegin()->first == 0;\n"
|
||||||
|
" }\n"
|
||||||
|
" bool g() {\n"
|
||||||
|
" return m.count(0);\n"
|
||||||
|
" }\n"
|
||||||
|
" std::map<int, int> m;\n"
|
||||||
|
"};\n");
|
||||||
|
ASSERT_EQUALS("[test.cpp:2]: (style, inconclusive) Technically the member function 'S::f' can be const.\n"
|
||||||
|
"[test.cpp:5]: (style, inconclusive) Technically the member function 'S::g' can be const.\n",
|
||||||
|
errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
void const_handleDefaultParameters() {
|
void const_handleDefaultParameters() {
|
||||||
checkConst("struct Foo {\n"
|
checkConst("struct Foo {\n"
|
||||||
" void foo1(int i, int j = 0) {\n"
|
" void foo1(int i, int j = 0) {\n"
|
||||||
|
|
Loading…
Reference in New Issue