From 2e78d2148092ca5b36d58ba0be16fc5c9cc0b5cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 11 Aug 2015 11:21:03 +0200 Subject: [PATCH] Fixed #6730 (ValueFlow: inner scope does not return (continue,throw)) --- lib/valueflow.cpp | 2 +- test/testvalueflow.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/valueflow.cpp b/lib/valueflow.cpp index 190308797..73bb648aa 100644 --- a/lib/valueflow.cpp +++ b/lib/valueflow.cpp @@ -262,7 +262,7 @@ static bool isReturn(const Token *tok) return true; // return/goto statement prev = prev->previous(); - while (prev && !Token::Match(prev, ";|{|}|return|goto|throw")) + while (prev && !Token::Match(prev, ";|{|}|return|goto|throw|continue|break")) prev = prev->previous(); return prev && prev->isName(); } diff --git a/test/testvalueflow.cpp b/test/testvalueflow.cpp index 76cb3eb46..3c5fc3e55 100644 --- a/test/testvalueflow.cpp +++ b/test/testvalueflow.cpp @@ -1283,6 +1283,14 @@ private: "}"; ASSERT_EQUALS(false, testValueOfX(code, 5U, 5)); + code = "void f(int x) {\n" // #6730 + " if (x == 5) {\n" + " if (z) continue; else throw e;\n" + " }\n" + " a = x;\n" + "}"; + ASSERT_EQUALS(false, testValueOfX(code, 5U, 5)); + // TODO: float code = "void f(float x) {\n" " if (x == 0.5) {}\n"