Fixed #10142 (FP uninitMemberVar with std::map)

This commit is contained in:
Daniel Marjamäki 2021-09-05 16:35:08 +02:00
parent 0335671b35
commit 045f21ee48
2 changed files with 15 additions and 1 deletions

View File

@ -1955,7 +1955,7 @@ const Token * Variable::declEndToken() const
{
Token const * declEnd = typeStartToken();
while (declEnd && !Token::Match(declEnd, "[;,)={]")) {
if (declEnd->link() && Token::Match(declEnd,"(|["))
if (declEnd->link() && Token::Match(declEnd,"(|[|<"))
declEnd = declEnd->link();
declEnd = declEnd->next();
}

View File

@ -108,6 +108,7 @@ private:
TEST_CASE(initvar_2constructors); // BUG 2270353
TEST_CASE(initvar_constvar);
TEST_CASE(initvar_staticvar);
TEST_CASE(initvar_brace_init);
TEST_CASE(initvar_union);
TEST_CASE(initvar_delegate); // ticket #4302
TEST_CASE(initvar_delegate2);
@ -1046,6 +1047,19 @@ private:
}
void initvar_brace_init() { // #10142
check("class C\n"
"{\n"
"public:\n"
" C() {}\n"
"\n"
"private:\n"
" std::map<int, double> * values_{};\n"
"};");
ASSERT_EQUALS("", errout.str());
}
void initvar_union() {
check("class Fred\n"
"{\n"