SymbolDatabase: better handling when array size is given with expression involving enum constants.

This commit is contained in:
Robert Reif 2016-05-13 11:40:19 +02:00 committed by Daniel Marjamäki
parent 1d21cf5755
commit 5631c765a7
1 changed files with 14 additions and 0 deletions

View File

@ -1289,6 +1289,20 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
dimension.num = dimension.end->enumerator()->value;
dimension.known = true;
}
} else {
// rhs of [
const Token *rhs = dimension.start->previous()->astOperand2();
if (rhs) {
// constant folding of expression:
ValueFlow::valueFlowConstantFoldAST(rhs);
// get constant folded value:
if (rhs->values.size() == 1U && rhs->values.front().isKnown()) {
dimension.num = rhs->values.front().intvalue;
dimension.known = true;
}
}
}
}
}