parent
16a4449901
commit
e1c51940a2
|
@ -1567,6 +1567,8 @@ void CheckOther::checkConstPointer()
|
|||
deref = true;
|
||||
else if (Token::simpleMatch(parent, "[") && parent->astOperand1() == tok && tok != nameTok)
|
||||
deref = true;
|
||||
else if (Token::Match(parent, "%op%") && Token::simpleMatch(parent->astParent(), "."))
|
||||
deref = true;
|
||||
if (deref) {
|
||||
const Token* const gparent = parent->astParent();
|
||||
if (Token::Match(gparent, "%cop%") && !gparent->isUnaryOp("&") && !gparent->isUnaryOp("*"))
|
||||
|
|
|
@ -3105,6 +3105,12 @@ private:
|
|||
" if (x == nullptr) {}\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (style) Parameter 'x' can be declared as pointer to const\n", errout.str());
|
||||
|
||||
check("struct S { void v(); };\n" // #11095
|
||||
"void f(S* s) {\n"
|
||||
" (s - 1)->v();\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void switchRedundantAssignmentTest() {
|
||||
|
|
Loading…
Reference in New Issue