skip nested anonymous unions when searching for variables in symbol database
This commit is contained in:
parent
57056bcf61
commit
31f8ff723b
|
@ -1447,6 +1447,11 @@ void Scope::getVariableList()
|
|||
else
|
||||
break;
|
||||
}
|
||||
else if (Token::Match(tok, "union {") && Token::Match(tok->next()->link(), "} %var% ;"))
|
||||
{
|
||||
tok = tok->next()->link()->next()->next();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Borland C++: Skip all variables in the __published section.
|
||||
// These are automatically initialized.
|
||||
|
|
|
@ -73,6 +73,7 @@ private:
|
|||
TEST_CASE(initvar_2constructors); // BUG 2270353
|
||||
TEST_CASE(initvar_constvar);
|
||||
TEST_CASE(initvar_staticvar);
|
||||
TEST_CASE(initvar_union);
|
||||
|
||||
TEST_CASE(initvar_private_constructor); // BUG 2354171 - private constructor
|
||||
TEST_CASE(initvar_copy_constructor); // ticket #1611
|
||||
|
@ -795,6 +796,38 @@ private:
|
|||
}
|
||||
|
||||
|
||||
void initvar_union()
|
||||
{
|
||||
check("class Fred\n"
|
||||
"{\n"
|
||||
" union\n"
|
||||
" {\n"
|
||||
" int a;\n"
|
||||
" char b[4];\n"
|
||||
" } U;\n"
|
||||
"public:\n"
|
||||
" Fred()\n"
|
||||
" {\n"
|
||||
" U.a = 0;\n"
|
||||
" }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("class Fred\n"
|
||||
"{\n"
|
||||
" union\n"
|
||||
" {\n"
|
||||
" int a;\n"
|
||||
" char b[4];\n"
|
||||
" } U;\n"
|
||||
"public:\n"
|
||||
" Fred()\n"
|
||||
" {\n"
|
||||
" }\n"
|
||||
"};\n");
|
||||
ASSERT_EQUALS("[test.cpp:9]: (warning) Member variable 'Fred::U' is not initialised in the constructor.\n", errout.str());
|
||||
}
|
||||
|
||||
|
||||
void initvar_private_constructor()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue