From 698e9e2b594685988c9b7140fafcb0bbd3aa8f37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 23 Sep 2013 17:52:42 +0200 Subject: [PATCH] reverted ee14ea4f. I think this fix was too generic. If there is a union in the struct then only the union members should be skipped. --- lib/checkuninitvar.cpp | 11 ----------- test/testuninitvar.cpp | 14 -------------- 2 files changed, 25 deletions(-) diff --git a/lib/checkuninitvar.cpp b/lib/checkuninitvar.cpp index 664a56231..b70754e24 100644 --- a/lib/checkuninitvar.cpp +++ b/lib/checkuninitvar.cpp @@ -1101,22 +1101,11 @@ void CheckUninitVar::checkScope(const Scope* scope) for (std::size_t j = 0U; j < symbolDatabase->classAndStructScopes.size(); ++j) { const Scope *scope2 = symbolDatabase->classAndStructScopes[j]; if (scope2->className == structname && scope2->numConstructors == 0U) { - bool hasUnion = false; - for (std::list::const_iterator childscope = scope2->nestedList.begin(); - childscope != scope2->nestedList.end(); - ++childscope) { - if ((*childscope)->type == Scope::eUnion) - hasUnion = true; - } - if (hasUnion) - break; - for (std::list::const_iterator it = scope2->varlist.begin(); it != scope2->varlist.end(); ++it) { const Variable &var = *it; if (!var.isArray()) checkScopeForVariable(scope, tok, *i, NULL, NULL, var.name()); } - break; } } } diff --git a/test/testuninitvar.cpp b/test/testuninitvar.cpp index a0172da7c..504338d58 100644 --- a/test/testuninitvar.cpp +++ b/test/testuninitvar.cpp @@ -2788,20 +2788,6 @@ private: "}\n", "test.c"); ASSERT_EQUALS("", errout.str()); - checkUninitVar2("struct PIXEL {\n" // union in struct #4970 - " union {\n" - " struct { unsigned char red,green,blue,alpha; };\n" - " unsigned int color;\n" - " };\n" - "};\n" - "\n" - "unsigned char f() {\n" - " struct PIXEL p1;\n" - " p1.color = 255;\n" - " return p1.red;\n" - "}"); - ASSERT_EQUALS("", errout.str()); - // return checkUninitVar2("struct AB { int a; int b; };\n" "void f(void) {\n"