diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 7f09418f0..87ea0e806 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -5090,7 +5090,7 @@ static void valueFlowSmartPointer(TokenList *tokenlist, ErrorLogger * errorLogge values.push_back(v); valueFlowForwardAssign(tok, var, values, false, true, tokenlist, errorLogger, settings); } - } else if (Token::Match(tok, "%var% . reset (")) { + } else if (Token::Match(tok, "%var% . reset (") && tok->next()->originalName() != "->") { if (Token::simpleMatch(tok->tokAt(3), "( )")) { std::list values; ValueFlow::Value v(0); @@ -5106,7 +5106,7 @@ static void valueFlowSmartPointer(TokenList *tokenlist, ErrorLogger * errorLogge const bool constValue = inTok->isNumber(); valueFlowForwardAssign(inTok, var, values, constValue, false, tokenlist, errorLogger, settings); } - } else if (Token::Match(tok, "%var% . release ( )")) { + } else if (Token::Match(tok, "%var% . release ( )") && tok->next()->originalName() != "->") { std::list values; ValueFlow::Value v(0); v.setKnown(); diff --git a/test/testnullpointer.cpp b/test/testnullpointer.cpp index 6922e11df..ecc7afa41 100644 --- a/test/testnullpointer.cpp +++ b/test/testnullpointer.cpp @@ -2339,6 +2339,17 @@ private: " p.reset(new const A*[n]);\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + // #9216 + check("struct A {\n" + " void reset();\n" + " void f();\n" + "};\n" + "void g(std::unique_ptr var) {\n" + " var->reset();\n" + " var->f();\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void functioncall() { // #3443 - function calls