ValueType: Set valuetype for sizeof argument

This commit is contained in:
Daniel Marjamäki 2016-07-20 09:39:48 +02:00
parent 3eef225b36
commit a68da1a725
2 changed files with 10 additions and 0 deletions

View File

@ -4468,6 +4468,13 @@ void SymbolDatabase::setValueTypeInTokenList(Token *tokens, bool cpp, char defau
ValueType valuetype(ValueType::Sign::UNSIGNED, ValueType::Type::LONG, 0U);
valuetype.originalTypeName = "size_t";
setValueType(tok, valuetype, cpp, defsign, lib);
if (Token::Match(tok, "( %type% %type%| *| *| )")) {
ValueType vt;
if (parsedecl(tok->next(), &vt, defsign, lib)) {
setValueType(tok->next(), vt, cpp, defsign, lib);
}
}
}
} else if (tok->variable()) {
setValueType(tok, *tok->variable(), cpp, defsign, lib);

View File

@ -3626,6 +3626,9 @@ private:
ASSERT_EQUALS("char", typeOf("a = static_cast<char>(32);", "("));
ASSERT_EQUALS("", typeOf("a = (unsigned x)0;", "("));
// sizeof..
ASSERT_EQUALS("char", typeOf("sizeof(char)", "char"));
// const..
ASSERT_EQUALS("const char *", typeOf("a = \"123\";", "\"123\""));
ASSERT_EQUALS("const signed int *", typeOf("const int *a; x = a + 1;", "a +"));