From 734b10e65085907de2f9b7348469248db0c2c7a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 2 Apr 2010 08:35:05 +0200 Subject: [PATCH] Fixed #1479 (false positive: unintialized variable when using goto) --- lib/executionpath.cpp | 7 +++++++ test/testother.cpp | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/executionpath.cpp b/lib/executionpath.cpp index abaab0a2c..4b7565ec2 100644 --- a/lib/executionpath.cpp +++ b/lib/executionpath.cpp @@ -91,6 +91,13 @@ static const Token *checkExecutionPaths_(const Token *tok, std::list bailout + if (tok->str() == "goto") + { + ExecutionPath::bailOut(checks); + return 0; + } + // for/while/switch/do .. bail out if (Token::Match(tok, "for|while|switch|do")) { diff --git a/test/testother.cpp b/test/testother.cpp index 8bb262268..7ae987a10 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -1390,6 +1390,15 @@ private: " return retval;\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + checkUninitVar("int foo()\n" + "{\n" + " int i;\n" + " goto exit;\n" + " i++;\n" + "exit:\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } // if..