From 5762084efa2e98d8251e047a7d4195da3410c7b5 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Dec 2022 10:58:30 -0600 Subject: [PATCH 1/2] Throw internal error when tokens are not in order --- lib/valueflow.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 85f90085416..02cabb5beb6 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -5329,6 +5329,8 @@ static void valueFlowForwardConst(Token* start, const Settings* const settings, 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()) { if (tok->varId() == var->declarationId()) { for (const ValueFlow::Value& value : values) From c4a21d3a44f210320f89bcd78c9e863d0654c5da Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 8 Dec 2022 14:54:03 -0600 Subject: [PATCH 2/2] Add semicolon --- lib/valueflow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 02cabb5beb6..48be45bdae3 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -5330,7 +5330,7 @@ static void valueFlowForwardConst(Token* start, int /*unused*/ = 0) { if (!precedes(start, end)) - throw InternalError(var->nameToken(), "valueFlowForwardConst: start token does not precede the end token.") + throw InternalError(var->nameToken(), "valueFlowForwardConst: start token does not precede the end token."); for (Token* tok = start; tok != end; tok = tok->next()) { if (tok->varId() == var->declarationId()) { for (const ValueFlow::Value& value : values)