* Fix #10825 CheckClass::isMemberVar found used member variable with varid 0 * Restore call to simpleMatch()
This commit is contained in:
parent
b1e92fc399
commit
6a8bd981b5
|
@ -2037,6 +2037,9 @@ bool CheckClass::isMemberVar(const Scope *scope, const Token *tok) const
|
|||
return true;
|
||||
} else if (Token::simpleMatch(tok->tokAt(-3), "( * this )")) {
|
||||
return true;
|
||||
} else if (Token::Match(tok->tokAt(-3), "%name% ) . %name%")) {
|
||||
tok = tok->tokAt(-3);
|
||||
again = true;
|
||||
} else if (Token::Match(tok->tokAt(-2), "%name% . %name%")) {
|
||||
tok = tok->tokAt(-2);
|
||||
again = true;
|
||||
|
|
|
@ -192,6 +192,7 @@ private:
|
|||
TEST_CASE(const73); // ticket #10735
|
||||
TEST_CASE(const74); // ticket #10671
|
||||
TEST_CASE(const75); // ticket #10065
|
||||
TEST_CASE(const76); // ticket #10825
|
||||
TEST_CASE(const_handleDefaultParameters);
|
||||
TEST_CASE(const_passThisToMemberOfOtherClass);
|
||||
TEST_CASE(assigningPointerToPointerIsNotAConstOperation);
|
||||
|
@ -5994,6 +5995,20 @@ private:
|
|||
ASSERT_EQUALS("[test.cpp:4]: (style, inconclusive) Technically the member function 'N::S::f' can be const.\n", errout.str());
|
||||
}
|
||||
|
||||
void const76() { // #10825
|
||||
checkConst("struct S {\n"
|
||||
" enum E {};\n"
|
||||
" void f(const T* t);\n"
|
||||
" E e;\n"
|
||||
"};\n"
|
||||
"struct T { void e(); };\n"
|
||||
"void S::f(const T* t) {\n"
|
||||
" const_cast<T*>(t)->e();\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:3]: (performance, inconclusive) Technically the member function 'S::f' can be static (but you may consider moving to unnamed namespace).\n",
|
||||
errout.str());
|
||||
}
|
||||
|
||||
void const_handleDefaultParameters() {
|
||||
checkConst("struct Foo {\n"
|
||||
" void foo1(int i, int j = 0) {\n"
|
||||
|
|
Loading…
Reference in New Issue