Fixed #5054 (debug warnings when Variable::typeStartToken() or Variable::typeEndTypen() is not set correctly)

This commit is contained in:
Daniel Marjamäki 2013-09-29 16:01:22 +02:00
parent d3798958f4
commit f96a88ec57
1 changed files with 21 additions and 0 deletions

View File

@ -3636,6 +3636,27 @@ bool Tokenizer::simplifyTokenList()
if (_settings->debugwarnings) {
printUnknownTypes();
// #5054 - the typeStartToken() should come before typeEndToken()
for (const Token *tok = tokens(); tok; tok = tok->next()) {
if (tok->varId() == 0U)
continue;
const Variable *var = tok->variable();
if (!var)
continue;
const Token * typetok = var->typeStartToken();
while (typetok && typetok != var->typeEndToken())
typetok = typetok->next();
if (typetok != var->typeEndToken()) {
reportError(tok,
Severity::debug,
"debug",
"Variable::typeStartToken() is not located before Variable::typeEndToken(). The location of the typeStartToken() is '" + var->typeStartToken()->str() + "' at line " + MathLib::toString(var->typeStartToken()->linenr()));
}
}
}
return true;