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