Fix FP redundantPointerOp (#4058)

* Fix #10991 FN: Redundant pointer operation

* Fix FP redundantPointerOp

* Check for LValue
This commit is contained in:
chrchr-github 2022-04-28 15:25:31 +02:00 committed by GitHub
parent 3d3885d151
commit 8dbe6994a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -2951,7 +2951,7 @@ void CheckOther::checkRedundantPointerOp()
// variable
const Token *varTok = tok->astOperand1()->astOperand1();
if (!varTok || varTok->isExpandedMacro())
if (!varTok || varTok->isExpandedMacro() || (!addressOfDeref && varTok->valueType() && varTok->valueType()->pointer && varTok->valueType()->reference == Reference::LValue))
continue;
const Variable *var = varTok->variable();

View File

@ -8774,6 +8774,9 @@ private:
"[test.cpp:4]: (style) Redundant pointer operation on 'value' - it's already a variable.\n",
errout.str());
check("void f(int**& p) {}\n", nullptr, false, true);
ASSERT_EQUALS("", errout.str());
// no warning for bitwise AND
check("void f(const int *b) {\n"
" int x = 0x20 & *b;\n"