Fixed #4754 (False positive: Map literals trigger redundant code warning)
This commit is contained in:
parent
9f8ce6f77f
commit
a5b044a6e2
|
@ -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%")) {
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in New Issue