From 405e17985a9c9d473496409ba739b5da318d93c7 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Mon, 2 Aug 2021 06:53:54 +0200 Subject: [PATCH] Add test case for ticket #9808 (#3366) --- test/testcondition.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/testcondition.cpp b/test/testcondition.cpp index 24f2c0720..acf6d7d5e 100644 --- a/test/testcondition.cpp +++ b/test/testcondition.cpp @@ -129,6 +129,7 @@ private: TEST_CASE(checkAssignmentInCondition); TEST_CASE(compareOutOfTypeRange); TEST_CASE(knownConditionCast); // #9976 + TEST_CASE(knownConditionIncrementLoop); // #9808 } void check(const char code[], Settings *settings, const char* filename = "test.cpp") { @@ -4380,6 +4381,16 @@ private: "}\n"); ASSERT_EQUALS("", errout.str()); } + + void knownConditionIncrementLoop() { // #9808 + check("void f() {\n" + " int a = 0;\n" + " while (++a < 5) {}\n" + " if (a == 1) {}\n" + " std::cout << a;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + } }; REGISTER_TEST(TestCondition)