Throw internal error when tokens are not in order (#4623)

* Throw internal error when tokens are not in order

* Add semicolon
This commit is contained in:
Paul Fultz II 2022-12-09 00:17:16 -06:00 committed by GitHub
parent 7acbb656f3
commit 6eccb2e36c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -5331,6 +5331,8 @@ static void valueFlowForwardConst(Token* start,
const Settings* const settings, const Settings* const settings,
int /*unused*/ = 0) int /*unused*/ = 0)
{ {
if (!precedes(start, end))
throw InternalError(var->nameToken(), "valueFlowForwardConst: start token does not precede the end token.");
for (Token* tok = start; tok != end; tok = tok->next()) { for (Token* tok = start; tok != end; tok = tok->next()) {
if (tok->varId() == var->declarationId()) { if (tok->varId() == var->declarationId()) {
for (const ValueFlow::Value& value : values) for (const ValueFlow::Value& value : values)