Fixed #5042 (false positive: Redundant code (set filled in initialization list))

This commit is contained in:
Daniel Marjamäki 2013-10-05 12:26:09 +02:00
parent 53adafb1f2
commit 6830d5f7a4
2 changed files with 8 additions and 0 deletions

View File

@ -2078,6 +2078,10 @@ void CheckOther::checkIncompleteStatement()
else if (Token::Match(tok,"> %var% {") || Token::Match(tok, "[;{}] return {"))
tok = tok->linkAt(2);
// C++11 initialize set in initalizer list : [,:] std::set<int>{1} [{,]
else if (Token::Match(tok,"> {") && tok->link())
tok = tok->next()->link();
else if (Token::Match(tok, "[;{}] %str%") || Token::Match(tok, "[;{}] %num%")) {
// No warning if numeric constant is followed by a "." or ","
if (Token::Match(tok->next(), "%num% [,.]"))

View File

@ -181,6 +181,10 @@ private:
check("A::A() : abc{0} {}");
ASSERT_EQUALS("", errout.str());
// #5042 - C++11 initializer list
check("A::A() : abc::def<int>{0} {}");
ASSERT_EQUALS("", errout.str());
// #4503 - vector init
check("void f() { vector<int> v{1}; }");
ASSERT_EQUALS("", errout.str());