Fixed #7966 (ValueType: wrong type for gcc initialization {[1]=..})

This commit is contained in:
Daniel Marjamäki 2017-03-31 09:41:38 +02:00
parent 16f9e1646c
commit 164df2aa7b
2 changed files with 2 additions and 1 deletions

View File

@ -4578,7 +4578,7 @@ void SymbolDatabase::setValueType(Token *tok, const ValueType &valuetype)
return;
}
if (parent->str() == "[" && (!cpp || parent->astOperand1() == tok) && valuetype.pointer > 0U) {
if (parent->str() == "[" && (!cpp || parent->astOperand1() == tok) && valuetype.pointer > 0U && !Token::Match(parent->previous(), "[{,]")) {
const Token *op1 = parent->astOperand1();
while (op1 && op1->str() == "[")
op1 = op1->astOperand1();

View File

@ -4429,6 +4429,7 @@ private:
// Variable declaration
ASSERT_EQUALS("char *", typeOf("; char abc[] = \"abc\";", "["));
ASSERT_EQUALS("", typeOf("; int x[10] = { [3]=1 };", "[ 3 ]"));
}
void variadic1() { // #7453