ValueFlow: Fix sizeof for array of library type
This commit is contained in:
parent
d5c5feafb2
commit
b984897526
|
@ -943,6 +943,8 @@ static Token * valueFlowSetConstantValue(const Token *tok, const Settings *setti
|
|||
size = settings->sizeof_int;
|
||||
if (var->type()->classScope && var->type()->classScope->enumType)
|
||||
size = getSizeOfType(var->type()->classScope->enumType, settings);
|
||||
} else if (var->valueType()) {
|
||||
size = getSizeOf(*var->valueType(), settings);
|
||||
} else if (!var->type()) {
|
||||
size = getSizeOfType(var->typeStartToken(), settings);
|
||||
}
|
||||
|
|
|
@ -924,6 +924,12 @@ private:
|
|||
CHECK(": wchar_t", settings.sizeof_wchar_t);
|
||||
CHECK(": size_t", settings.sizeof_size_t);
|
||||
#undef CHECK
|
||||
|
||||
code = "uint16_t arr[10];\n"
|
||||
"x = sizeof(arr);";
|
||||
values = tokenValues(code,"( arr )");
|
||||
ASSERT_EQUALS(1U, values.size());
|
||||
ASSERT_EQUALS(10 * sizeof(uint16_t), values.back().intvalue);
|
||||
}
|
||||
|
||||
void valueFlowErrorPath() {
|
||||
|
|
Loading…
Reference in New Issue