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;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Token::Match(tok, "break|continue|return|throw")) {
|
if (Token::Match(tok, "break|continue|return|throw|goto")) {
|
||||||
// TODO: handle these better
|
// TODO: handle these better
|
||||||
*read = true;
|
*read = true;
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -1932,6 +1932,14 @@ private:
|
|||||||
"}\n", nullptr, false, false, true);
|
"}\n", nullptr, false, false, true);
|
||||||
ASSERT_EQUALS("", errout.str());
|
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() {
|
void switchRedundantOperationTest() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user