* Add test case for ticket #9808 * Add test case for ticket #6884
This commit is contained in:
parent
3d19b33c3e
commit
ba00046732
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue