Add test case for ticket #6884 (#3375)

* Add test case for ticket #9808

* Add test case for ticket #6884
This commit is contained in:
chrchr-github 2021-08-02 13:21:18 +02:00 committed by GitHub
parent 3d19b33c3e
commit ba00046732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 0 deletions

View File

@ -246,6 +246,7 @@ private:
// Access array and then check if the used index is within bounds
TEST_CASE(arrayIndexThenCheck);
TEST_CASE(arrayIndexEarlyReturn); // #6884
TEST_CASE(bufferNotZeroTerminated);
@ -4309,6 +4310,21 @@ private:
ASSERT_EQUALS("", errout.str());
}
void arrayIndexEarlyReturn() { // #6884
check("extern const char *Names[2];\n"
"const char* getName(int value) {\n"
" if ((value < 0) || (value > 1))\n"
" return \"???\";\n"
" const char* name = Names[value]; \n"
" switch (value) {\n"
" case 2:\n"
" break; \n"
" }\n"
" return name;\n"
"}\n");
ASSERT_EQUALS("", errout.str());
}
void bufferNotZeroTerminated() {
check("void f() {\n"
" char c[6];\n"