Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/vf_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ namespace ValueFlow
setTokenValue(tok->tokAt(4), std::move(value), settings);
}
} else if (Token::Match(tok2, "%var% )")) {
const Variable *var = tok2->variable();
// only look for single token types (no pointers or references yet)
if (var && var->typeStartToken() == var->typeEndToken()) {
if (const Variable *var = tok2->variable()) {
// find the size of the type
size_t size = 0;
if (var->isEnumType()) {
Expand Down
9 changes: 9 additions & 0 deletions test/testvalueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1742,6 +1742,15 @@ class TestValueFlow : public TestFixture {
values = tokenValues(code, "( D )");
ASSERT_EQUALS(1U, values.size());
TODO_ASSERT_EQUALS(2 * settings.platform.sizeof_pointer, 1, values.back().intvalue);

code = "int f() {\n" // #11335
" int* a[2];"
" return sizeof(a);\n"
"}";
values = tokenValues(code, "( a");
ASSERT_EQUALS(1U, values.size());
ASSERT_EQUALS(16, values.back().intvalue);
ASSERT_EQUALS_ENUM(ValueFlow::Value::ValueKind::Known, values.back().valueKind);
}

void valueFlowComma()
Expand Down
Loading