diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 83d83c948..0f2406f74 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -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;