diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 28b87b053..bed278f5c 100755 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -6538,6 +6538,11 @@ void SymbolDatabase::setValueTypeInTokenList(bool reportDebugWarnings, Token *to setValueType(tok, valuetype); } + else if (Token::simpleMatch(tok->previous(), "= {") && tok->tokAt(-2) && tok->tokAt(-2)->valueType()) { + ValueType vt = *tok->tokAt(-2)->valueType(); + setValueType(tok, vt); + } + // library type/function else if (tok->previous()) { if (tok->astParent() && Token::Match(tok->astOperand1(), "%name%|::")) { diff --git a/test/testautovariables.cpp b/test/testautovariables.cpp old mode 100755 new mode 100644 index c409178fc..fa6d9d7c3 --- a/test/testautovariables.cpp +++ b/test/testautovariables.cpp @@ -2474,6 +2474,13 @@ private: true); ASSERT_EQUALS("", errout.str()); + check("std::string f(std::string s) {\n" + " std::string r = { s.begin(), s.end() };\n" + " return r;\n" + "}\n", + true); + ASSERT_EQUALS("", errout.str()); + check("struct A {\n" " std::vector> mA;\n" " void f(std::unique_ptr a) {\n"