diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 667717058..a8cf1b09f 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -1368,6 +1368,8 @@ const Token * getTokenArgumentFunction(const Token * tok, int& argn) parent = parent->astParent(); while (parent && parent->isCast()) parent = parent->astParent(); + if (Token::Match(parent, "[+-]") && parent->valueType() && parent->valueType()->pointer) + parent = parent->astParent(); // passing variable to subfunction? if (Token::Match(parent, "[(,{]")) diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 06aa3509f..9b0a9797e 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -4109,6 +4109,17 @@ private: "}"; values = tokenValues(code, "szHdr ; }"); ASSERT_EQUALS(0, values.size()); + + // #9933 + code = "struct MyStruct { size_t value; }\n" + "\n" + "void foo() {\n" + " MyStruct x;\n" + " fread(((char *)&x) + 0, sizeof(x), f);\n" + " if (x.value < 432) {}\n" + "}"; + values = tokenValues(code, "x . value"); + ASSERT_EQUALS(0, values.size()); } void valueFlowTerminatingCond() {