Fixed #5707 (false negative: unreachable code is not detected (code after return))
This commit is contained in:
parent
3c5cf299e3
commit
87354bf9d2
|
@ -1619,6 +1619,7 @@ void CheckOther::checkUnreachableCode()
|
|||
|
||||
if (!tok)
|
||||
break;
|
||||
tok = tok->previous(); // Will be advanced again by for loop
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3079,6 +3079,17 @@ private:
|
|||
"}", 0, false, false, false, false);
|
||||
ASSERT_EQUALS("[test.cpp:4]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout.str());
|
||||
|
||||
// #5707
|
||||
check("extern int i,j\n"
|
||||
"int foo() {\n"
|
||||
" switch(i) {\n"
|
||||
" default: j=1; break;\n"
|
||||
" }\n"
|
||||
" return 0;\n"
|
||||
" j=2;\n"
|
||||
"}", 0, false, false, false, false);
|
||||
ASSERT_EQUALS("[test.cpp:7]: (style) Statements following return, break, continue, goto or throw will never be executed.\n", errout.str());
|
||||
|
||||
check("int foo() {\n"
|
||||
" return 0;\n"
|
||||
" label:\n"
|
||||
|
|
Loading…
Reference in New Issue