redundantAssignmentInSwitch: fix false positive when there is goto
This commit is contained in:
parent
d2bd536f1b
commit
2f66b31d43
|
@ -471,7 +471,7 @@ const Token *CheckOther::checkRedundantAssignmentRecursive(const Token *assign1,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
if (Token::Match(tok, "break|continue|return|throw")) {
|
||||
if (Token::Match(tok, "break|continue|return|throw|goto")) {
|
||||
// TODO: handle these better
|
||||
*read = true;
|
||||
return nullptr;
|
||||
|
|
|
@ -1932,6 +1932,14 @@ private:
|
|||
"}\n", nullptr, false, false, true);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void f() {\n"
|
||||
" int x;\n"
|
||||
" switch (state) {\n"
|
||||
" case 1: x = 3; goto a;\n"
|
||||
" case 1: x = 6; goto a;\n"
|
||||
" }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void switchRedundantOperationTest() {
|
||||
|
|
Loading…
Reference in New Issue