Fix FN constVariableReference (#4949)
This commit is contained in:
parent
ac14fd218b
commit
a0b59ff56a
|
@ -1471,6 +1471,8 @@ void CheckOther::checkConstVariable()
|
||||||
if (tok->isUnaryOp("&") && Token::Match(tok, "& %varid%", var->declarationId())) {
|
if (tok->isUnaryOp("&") && Token::Match(tok, "& %varid%", var->declarationId())) {
|
||||||
const Token* opTok = tok->astParent();
|
const Token* opTok = tok->astParent();
|
||||||
int argn = -1;
|
int argn = -1;
|
||||||
|
if (opTok && opTok->isUnaryOp("!"))
|
||||||
|
continue;
|
||||||
if (opTok && (opTok->isComparisonOp() || opTok->isAssignmentOp() || opTok->isCalculation())) {
|
if (opTok && (opTok->isComparisonOp() || opTok->isAssignmentOp() || opTok->isCalculation())) {
|
||||||
if (opTok->isComparisonOp() || opTok->isCalculation()) {
|
if (opTok->isComparisonOp() || opTok->isCalculation()) {
|
||||||
if (opTok->astOperand1() != tok)
|
if (opTok->astOperand1() != tok)
|
||||||
|
|
|
@ -3502,7 +3502,7 @@ private:
|
||||||
" int& r = i;\n"
|
" int& r = i;\n"
|
||||||
" if (!&r) {}\n"
|
" if (!&r) {}\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
TODO_ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'r' can be declared as reference to const\n", "", errout.str()); // don't crash
|
ASSERT_EQUALS("[test.cpp:2]: (style) Variable 'r' can be declared as reference to const\n", errout.str()); // don't crash
|
||||||
|
|
||||||
check("class C;\n" // #11646
|
check("class C;\n" // #11646
|
||||||
"void g(const C* const p);\n"
|
"void g(const C* const p);\n"
|
||||||
|
|
Loading…
Reference in New Issue