Fixed #4754 (False positive: Map literals trigger redundant code warning)

This commit is contained in:
Daniel Marjamäki 2013-04-20 07:51:44 +02:00
parent 9f8ce6f77f
commit a5b044a6e2
2 changed files with 11 additions and 2 deletions

View File

@ -2056,8 +2056,8 @@ void CheckOther::checkIncompleteStatement()
else if (tok->str() == "{" && Token::Match(tok->tokAt(-2), ",|: %var%") && Token::Match(tok->link(), "} [,{]"))
tok = tok->link();
// C++11 vector initialization
else if (Token::Match(tok,"> %var% {"))
// C++11 vector initialization / return { .. }
else if (Token::Match(tok,"> %var% {") || Token::Match(tok, "[;{}] return {"))
tok = tok->linkAt(2);
else if (Token::Match(tok, "[;{}] %str%") || Token::Match(tok, "[;{}] %num%")) {

View File

@ -191,6 +191,15 @@ private:
" return (struct s){0,0};\n"
"}");
ASSERT_EQUALS("", errout.str());
// #4754
check("unordered_map<string, string> foo() {\n"
" return {\n"
" {\"hi\", \"there\"},\n"
" {\"happy\", \"sad\"}\n"
" };\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void cast() {