diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index ec7f566b3..c426f8138 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -4802,22 +4802,25 @@ static const Token * parsedecl(const Token *type, ValueType * const valuetype, V valuetype->sign = ValueType::Sign::UNSIGNED; if (type->str() == "const") valuetype->constness |= (1 << (valuetype->pointer - pointer0)); - else if (Token::Match(type, "%name% :: %name%")) { - const Library::Container *container = settings->library.detectContainer(type); - if (container) { - valuetype->type = ValueType::Type::CONTAINER; - valuetype->container = container; - } else { - std::string typestr; - const Token *end = type; - while (Token::Match(end, "%name% :: %name%")) { - typestr += end->str() + "::"; - end = end->tokAt(2); - } - typestr += end->str(); - if (valuetype->fromLibraryType(typestr, settings)) - type = end; + else if (const Library::Container *container = settings->library.detectContainer(type)) { + valuetype->type = ValueType::Type::CONTAINER; + valuetype->container = container; + while (Token::Match(type, "%name%|::|<")) { + if (type->str() == "<" && type->link()) + type = type->link(); + type = type->next(); } + continue; + } else if (Token::Match(type, "%name% :: %name%")) { + std::string typestr; + const Token *end = type; + while (Token::Match(end, "%name% :: %name%")) { + typestr += end->str() + "::"; + end = end->tokAt(2); + } + typestr += end->str(); + if (valuetype->fromLibraryType(typestr, settings)) + type = end; } else if (ValueType::Type::UNKNOWN_TYPE != ValueType::typeFromString(type->str(), type->isLong())) valuetype->type = ValueType::typeFromString(type->str(), type->isLong()); else if (type->str() == "auto") { diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 7fc171a1d..5751dedb4 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -4438,6 +4438,7 @@ private: c.startPattern = "C"; sC.library.containers["C"] = c; ASSERT_EQUALS("container(C) *", typeOf("C*c=new C;","new","test.cpp",&sC)); + ASSERT_EQUALS("container(C) *", typeOf("x=(C*)c;","(","test.cpp",&sC)); } // new