File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -230,9 +230,7 @@ namespace ValueFlow
230230 setTokenValue (tok->tokAt (4 ), std::move (value), settings);
231231 }
232232 } else if (Token::Match (tok2, " %var% )" )) {
233- const Variable *var = tok2->variable ();
234- // only look for single token types (no pointers or references yet)
235- if (var && var->typeStartToken () == var->typeEndToken ()) {
233+ if (const Variable *var = tok2->variable ()) {
236234 // find the size of the type
237235 size_t size = 0 ;
238236 if (var->isEnumType ()) {
Original file line number Diff line number Diff line change @@ -1742,6 +1742,15 @@ class TestValueFlow : public TestFixture {
17421742 values = tokenValues (code, " ( D )" );
17431743 ASSERT_EQUALS (1U , values.size ());
17441744 TODO_ASSERT_EQUALS (2 * settings.platform .sizeof_pointer , 1 , values.back ().intvalue );
1745+
1746+ code = " int f() {\n " // #11335
1747+ " int* a[2];"
1748+ " return sizeof(a);\n "
1749+ " }" ;
1750+ values = tokenValues (code, " ( a" );
1751+ ASSERT_EQUALS (1U , values.size ());
1752+ ASSERT_EQUALS (2 * settings.platform .sizeof_pointer , values.back ().intvalue );
1753+ ASSERT_EQUALS_ENUM (ValueFlow::Value::ValueKind::Known, values.back ().valueKind );
17451754 }
17461755
17471756 void valueFlowComma ()
You can’t perform that action at this time.
0 commit comments