This commit is contained in:
parent
d204c5f894
commit
242afc389d
|
@ -1556,6 +1556,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;
|
||||||
else if (astIsRangeBasedForDecl(tok))
|
else if (astIsRangeBasedForDecl(tok))
|
||||||
continue;
|
continue;
|
||||||
if (deref) {
|
if (deref) {
|
||||||
|
@ -1577,7 +1579,7 @@ void CheckOther::checkConstPointer()
|
||||||
} else if (Token::simpleMatch(gparent, "[") && gparent->astOperand2() == parent)
|
} else if (Token::simpleMatch(gparent, "[") && gparent->astOperand2() == parent)
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
if (Token::Match(parent, "%oror%|%comp%|&&|?|!"))
|
if (Token::Match(parent, "%oror%|%comp%|&&|?|!|-"))
|
||||||
continue;
|
continue;
|
||||||
else if (Token::simpleMatch(parent, "(") && Token::Match(parent->astOperand1(), "if|while"))
|
else if (Token::simpleMatch(parent, "(") && Token::Match(parent->astOperand1(), "if|while"))
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -3250,6 +3250,13 @@ private:
|
||||||
" **b = 0;\n"
|
" **b = 0;\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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() {
|
void switchRedundantAssignmentTest() {
|
||||||
|
|
Loading…
Reference in New Issue