SymbolDatabase: fix ValueType for '&array[x]'

This commit is contained in:
Daniel Marjamäki 2022-11-05 21:22:08 +01:00
parent ecb2938e7e
commit e45e5f9f15
2 changed files with 1 additions and 2 deletions

View File

@ -6211,8 +6211,6 @@ void SymbolDatabase::setValueType(Token* tok, const ValueType& valuetype, Source
for (const Token* child = parent->astOperand1(); child;) {
if (Token::Match(child, ".|::"))
child = child->astOperand2();
else if (Token::simpleMatch(child, "["))
child = child->astOperand1();
else {
isArrayToPointerDecay = child->variable() && child->variable()->isArray();
break;

View File

@ -7602,6 +7602,7 @@ private:
ASSERT_EQUALS("", typeOf("a = x[\"hello\"];", "[", "test.cpp"));
ASSERT_EQUALS("const char", typeOf("a = x[\"hello\"];", "[", "test.c"));
ASSERT_EQUALS("signed int *", typeOf("int x[10]; a = &x;", "&"));
ASSERT_EQUALS("signed int *", typeOf("int x[10]; a = &x[1];", "&"));
// cast..
ASSERT_EQUALS("void *", typeOf("a = (void *)0;", "("));