diff --git a/lib/checkother.cpp b/lib/checkother.cpp index d669a776b..80b9b4b9b 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -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; diff --git a/test/testother.cpp b/test/testother.cpp index ec3931dbd..9603ff6de 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -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() {