ValueType: handle scoped types in parsedecl

This commit is contained in:
Daniel Marjamäki 2017-03-05 01:21:02 +01:00
parent 2f2ac46243
commit 920398615d
2 changed files with 13 additions and 1 deletions

View File

@ -4648,7 +4648,16 @@ 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 (ValueType::Type t = ValueType::typeFromString(type->str(), type->isLong()))
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);
}
if (valuetype->fromLibraryType(typestr + end->str(), settings))
type = end;
} else if (ValueType::Type t = ValueType::typeFromString(type->str(), type->isLong()))
valuetype->type = t;
else if (type->str() == "auto") {
if (!type->valueType())

View File

@ -4289,10 +4289,13 @@ private:
settingsWin64.platformType = Settings::Win64;
const Library::PodType u32 = { 4, 'u' };
settingsWin64.library.podtypes["u32"] = u32;
settingsWin64.library.podtypes["xyz::u32"] = u32;
ValueType vt;
ASSERT_EQUALS(true, vt.fromLibraryType("u32", &settingsWin64));
ASSERT_EQUALS(true, vt.fromLibraryType("xyz::u32", &settingsWin64));
ASSERT_EQUALS(ValueType::Type::INT, vt.type);
ASSERT_EQUALS("unsigned int *", typeOf(";void *data = new u32[10];", "new", "test.cpp", &settingsWin64));
ASSERT_EQUALS("unsigned int", typeOf("; x = (xyz::u32)12;", "(", "test.cpp", &settingsWin64));
}
{
// PlatformType