Fixed knownArgument false positive for pointer

This commit is contained in:
Daniel Marjamäki 2020-09-24 19:48:20 +02:00
parent c08e1a9a94
commit 801cc8d331
2 changed files with 6 additions and 1 deletions

View File

@ -3120,7 +3120,7 @@ void CheckOther::checkKnownArgument()
std::string varexpr; std::string varexpr;
visitAstNodes(tok, [&varexpr](const Token *child) { visitAstNodes(tok, [&varexpr](const Token *child) {
if (Token::Match(child, "%var%|.|[")) { if (Token::Match(child, "%var%|.|[")) {
if (child->valueType() && child->valueType()->isIntegral() && child->values().empty()) { if (child->valueType() && child->valueType()->pointer == 0 && child->valueType()->isIntegral() && child->values().empty()) {
varexpr = child->expressionString(); varexpr = child->expressionString();
return ChildrenToVisit::done; return ChildrenToVisit::done;
} }

View File

@ -8837,6 +8837,11 @@ private:
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("void foo(char *c) {\n"
" if (*c == '+' && (operand || !isalnum(*c))) {}\n"
"}");
ASSERT_EQUALS("", errout.str());
// #8986 // #8986
check("void f(int);\n" check("void f(int);\n"
"void g() {\n" "void g() {\n"