Fixed #7970 (ValueType: no types set below 'new std::string')

This commit is contained in:
Daniel Marjamäki 2017-04-01 22:22:37 +02:00
parent c883f850f5
commit b7dcdc00d0
2 changed files with 3 additions and 2 deletions

View File

@ -5037,7 +5037,7 @@ void SymbolDatabase::setValueTypeInTokenList()
typeTok = typeTok->tokAt(2);
}
if (!Token::Match(typeTok, "%type% ;|[|("))
return;
continue;
typestr += typeTok->str();
ValueType vt;
vt.pointer = 1;
@ -5049,7 +5049,7 @@ void SymbolDatabase::setValueTypeInTokenList()
if (vt.type == ValueType::Type::UNKNOWN_TYPE)
vt.fromLibraryType(typestr, _settings);
if (vt.type == ValueType::Type::UNKNOWN_TYPE)
return;
continue;
if (typeTok->isUnsigned())
vt.sign = ValueType::Sign::UNSIGNED;
else if (typeTok->isSigned())

View File

@ -4439,6 +4439,7 @@ private:
ASSERT_EQUALS("signed int", typeOf("; auto x = 3;", "x"));
ASSERT_EQUALS("signed int *", typeOf("; auto *p = (int *)0;", "p"));
ASSERT_EQUALS("signed int *", typeOf("; auto data = new int[100];", "data"));
ASSERT_EQUALS("signed int", typeOf("; auto data = new std::string; int x=1000; x=x/5;", "/")); // #7970
ASSERT_EQUALS("signed int *", typeOf("; auto data = new (nothrow) int[100];", "data"));
ASSERT_EQUALS("signed int *", typeOf("; auto data = new (std::nothrow) int[100];", "data"));
ASSERT_EQUALS("const signed short", typeOf("short values[10]; void f() { for (const auto *x : values); }", "x"));