Add test case for ticket #9808 (#3366)

This commit is contained in:
chrchr-github 2021-08-02 06:53:54 +02:00 committed by GitHub
parent 0f0d042ee2
commit 405e17985a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -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)