diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 7db4e888e..442e98292 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -5672,6 +5672,8 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V valuetype->smartPointerType = argTok->next()->type(); valuetype->type = ValueType::Type::NONSTD; type = argTok->link(); + if (type) + type = type->next(); continue; } else if (Token::Match(type, "%name% :: %name%")) { std::string typestr; diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 603f7050d..f2af95f95 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -156,6 +156,7 @@ private: TEST_CASE(VariableValueType2); TEST_CASE(VariableValueType3); TEST_CASE(VariableValueType4); // smart pointer type + TEST_CASE(VariableValueType5); // smart pointer type TEST_CASE(findVariableType1); TEST_CASE(findVariableType2); @@ -950,6 +951,16 @@ private: ASSERT(x->valueType()->smartPointerType); } + void VariableValueType5() { + GET_SYMBOL_DB("class C {};\n" + "void foo(std::shared_ptr* p) {}\n"); + + const Variable* const p = db->getVariableFromVarId(1); + ASSERT(p->valueType()); + ASSERT(p->valueType()->smartPointerTypeToken); + ASSERT(p->valueType()->pointer == 1); + } + void findVariableType1() { GET_SYMBOL_DB("class A {\n" "public:\n"