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())) {
|
||||
const Token* opTok = tok->astParent();
|
||||
int argn = -1;
|
||||
if (opTok && opTok->isUnaryOp("!"))
|
||||
continue;
|
||||
if (opTok && (opTok->isComparisonOp() || opTok->isAssignmentOp() || opTok->isCalculation())) {
|
||||
if (opTok->isComparisonOp() || opTok->isCalculation()) {
|
||||
if (opTok->astOperand1() != tok)
|
||||
|
|
|
@ -3502,7 +3502,7 @@ private:
|
|||
" int& r = i;\n"
|
||||
" if (!&r) {}\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
|
||||
"void g(const C* const p);\n"
|
||||
|
|
Loading…
Reference in New Issue