Skip to content

Commit 164df2a

Browse files
committed
Fixed #7966 (ValueType: wrong type for gcc initialization {[1]=..})
1 parent 16f9e16 commit 164df2a

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

lib/symboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4578,7 +4578,7 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)
45784578
return;
45794579
}
45804580

4581-
if (parent->str() == "[" && (!cpp || parent->astOperand1() == tok) && valuetype.pointer > 0U) {
4581+
if (parent->str() == "[" && (!cpp || parent->astOperand1() == tok) && valuetype.pointer > 0U && !Token::Match(parent->previous(), "[{,]")) {
45824582
const Token *op1 = parent->astOperand1();
45834583
while (op1 && op1->str() == "[")
45844584
op1 = op1->astOperand1();

test/testsymboldatabase.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4429,6 +4429,7 @@ class TestSymbolDatabase: public TestFixture {
44294429

44304430
// Variable declaration
44314431
ASSERT_EQUALS("char *", typeOf("; char abc[] = \"abc\";", "["));
4432+
ASSERT_EQUALS("", typeOf("; int x[10] = { [3]=1 };", "[ 3 ]"));
44324433
}
44334434

44344435
void variadic1() { // #7453

0 commit comments

Comments
 (0)