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)