throwing an exception is a valid immediate exit from switch
This commit is contained in:
parent
79f0fe7d1c
commit
2716b856f4
|
@ -270,7 +270,7 @@ void CheckOther::checkSizeofForArrayParameter()
|
|||
void CheckOther::checkRedundantAssignmentInSwitch()
|
||||
{
|
||||
const char switchPattern[] = "switch ( %any% ) { case";
|
||||
const char breakPattern[] = "break|continue|return|exit|goto";
|
||||
const char breakPattern[] = "break|continue|return|exit|goto|throw";
|
||||
const char functionPattern[] = "%var% (";
|
||||
|
||||
// Find the beginning of a switch. E.g.:
|
||||
|
@ -348,7 +348,7 @@ void CheckOther::checkSwitchCaseFallThrough()
|
|||
return;
|
||||
|
||||
const char switchPattern[] = "switch (";
|
||||
const char breakPattern[] = "break|continue|return|exit|goto";
|
||||
const char breakPattern[] = "break|continue|return|exit|goto|throw";
|
||||
|
||||
// Find the beginning of a switch. E.g.:
|
||||
// switch (var) { ...
|
||||
|
|
|
@ -1180,6 +1180,22 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo()\n"
|
||||
"{\n"
|
||||
" int y = 1;\n"
|
||||
" while(xyz()) {\n"
|
||||
" switch (x)\n"
|
||||
" {\n"
|
||||
" case 2:\n"
|
||||
" y = 2;\n"
|
||||
" throw e;\n"
|
||||
" case 3:\n"
|
||||
" y = 3;\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo()\n"
|
||||
"{\n"
|
||||
" int y = 1;\n"
|
||||
|
@ -1222,6 +1238,27 @@ private:
|
|||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check_preprocess_suppress(
|
||||
"void foo() {\n"
|
||||
" switch (a) {\n"
|
||||
" case 1:\n"
|
||||
" break;\n"
|
||||
" case 2:\n"
|
||||
" continue;\n"
|
||||
" case 3:\n"
|
||||
" return;\n"
|
||||
" case 4:\n"
|
||||
" exit(1);\n"
|
||||
" case 5:\n"
|
||||
" goto end;\n"
|
||||
" case 6:\n"
|
||||
" throw e;\n"
|
||||
" case 7:\n"
|
||||
" break;\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check_preprocess_suppress(
|
||||
"void foo() {\n"
|
||||
" switch (a) {\n"
|
||||
|
|
Loading…
Reference in New Issue