From d9cf70c1c678d575481c0efba52a6e30382b40c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 20 Dec 2009 13:55:17 +0100 Subject: [PATCH] Fixed #1119 (false positve: uninitialized variable y when y is assigned in inner expression 'x = (y = 10)') --- lib/executionpath.cpp | 2 +- test/testother.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/executionpath.cpp b/lib/executionpath.cpp index 409feb4a0..f389260ca 100644 --- a/lib/executionpath.cpp +++ b/lib/executionpath.cpp @@ -41,7 +41,7 @@ const Token *checkExecutionPaths(const Token *tok, std::list &c return 0; } - if (Token::Match(tok, "= {|(")) + if (Token::Match(tok, "= {") || Token::Match(tok, "= ( %type% !!=")) { tok = tok->next()->link(); if (Token::simpleMatch(tok, ") {")) diff --git a/test/testother.cpp b/test/testother.cpp index 184ca291e..5e4288124 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -981,6 +981,14 @@ private: "}\n"); ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: p\n", errout.str()); + checkUninitVar("static void foo()\n" + "{\n" + " int x, y;\n" + " x = (y = 10);\n" + " int z = y * 2;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); + checkUninitVar("static void foo()\n" "{\n" " Foo p;\n"