From 4c8b17c04018c8faac958197c49c1795daeb86dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 9 Apr 2013 17:02:11 +0200 Subject: [PATCH] Fixed #4717 (False positive: Uninitialized variable inside ({..})) --- lib/checkuninitvar.cpp | 2 ++ test/testuninitvar.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 7d755ed72..90e3268a3 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1084,6 +1084,8 @@ void CheckUninitVar::checkScope(const Scope* scope) } while (tok && tok->str() != ";") tok = tok->next(); + if (Token::findsimplematch(i->typeStartToken(), "=", tok)) + continue; if (stdtype || i->isPointer()) checkScopeForVariable(scope, tok, *i, NULL, NULL, ""); if (Token::Match(i->typeStartToken(), "struct %type% %var% ;")) { diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index b86b742be..e92e133d6 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -2350,6 +2350,11 @@ private: " x((A)(B)&a);\n" "}"); ASSERT_EQUALS("", errout.str()); + + checkUninitVar2("void f() {\n" // #4717 - ({}) + " int a = ({ long b = (long)(123); 2 + b; });\n" + "}", "test.c"); + ASSERT_EQUALS("", errout.str()); } // #3869 - reference variable