This commit is contained in:
parent
d204c5f894
commit
242afc389d
|
@ -1556,6 +1556,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;
|
||||
else if (astIsRangeBasedForDecl(tok))
|
||||
continue;
|
||||
if (deref) {
|
||||
|
@ -1577,7 +1579,7 @@ void CheckOther::checkConstPointer()
|
|||
} else if (Token::simpleMatch(gparent, "[") && gparent->astOperand2() == parent)
|
||||
continue;
|
||||
} else {
|
||||
if (Token::Match(parent, "%oror%|%comp%|&&|?|!"))
|
||||
if (Token::Match(parent, "%oror%|%comp%|&&|?|!|-"))
|
||||
continue;
|
||||
else if (Token::simpleMatch(parent, "(") && Token::Match(parent->astOperand1(), "if|while"))
|
||||
continue;
|
||||
|
|
|
@ -3250,6 +3250,13 @@ private:
|
|||
" **b = 0;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("ptrdiff_t f(int *p0, int *p1) {\n" // #11148
|
||||
" return p0 - p1;\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:1]: (style) Parameter 'p0' can be declared as pointer to const\n"
|
||||
"[test.cpp:1]: (style) Parameter 'p1' can be declared as pointer to const\n",
|
||||
errout.str());
|
||||
}
|
||||
|
||||
void switchRedundantAssignmentTest() {
|
||||
|
|
Loading…
Reference in New Issue