From 801cc8d33121906da8515a05c32bbcdcfd390739 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Thu, 24 Sep 2020 19:48:20 +0200 Subject: [PATCH] Fixed knownArgument false positive for pointer --- lib/checkother.cpp | 2 +- test/testother.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/checkother.cpp b/lib/checkother.cpp index cf43bff0f..88d495ad3 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -3120,7 +3120,7 @@ void CheckOther::checkKnownArgument() std::string varexpr; visitAstNodes(tok, [&varexpr](const Token *child) { 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(); return ChildrenToVisit::done; } diff --git a/test/testother.cpp b/test/testother.cpp index a8c5719d1..a4c5f145d 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -8837,6 +8837,11 @@ private: "}"); ASSERT_EQUALS("", errout.str()); + check("void foo(char *c) {\n" + " if (*c == '+' && (operand || !isalnum(*c))) {}\n" + "}"); + ASSERT_EQUALS("", errout.str()); + // #8986 check("void f(int);\n" "void g() {\n"