Fixed #8449 (False positive 'constStatement' when initializing std::unordered_map)
This commit is contained in:
parent
2d61ca8883
commit
69e7392ce2
|
@ -1615,10 +1615,9 @@ void CheckOther::checkIncompleteStatement()
|
|||
tok = tok->link();
|
||||
|
||||
// C++11 struct/array/etc initialization in initializer list
|
||||
else if (Token::Match(tok->previous(), "%name%|] {") && !Token::findsimplematch(tok,";",tok->link()))
|
||||
else if (Token::Match(tok->previous(), "%var%|] {"))
|
||||
tok = tok->link();
|
||||
|
||||
|
||||
if (!Token::Match(tok, "[;{}] %str%|%num%"))
|
||||
continue;
|
||||
|
||||
|
|
|
@ -79,6 +79,7 @@ private:
|
|||
TEST_CASE(cast); // #3009 : (struct Foo *)123.a = 1;
|
||||
TEST_CASE(increment); // #3251 : FP for increment
|
||||
TEST_CASE(cpp11init); // #5493 : int i{1};
|
||||
TEST_CASE(cpp11init2); // #8449
|
||||
TEST_CASE(block); // ({ do_something(); 0; })
|
||||
TEST_CASE(mapindex);
|
||||
}
|
||||
|
@ -272,6 +273,13 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void cpp11init2() {
|
||||
check("x<string> handlers{\n"
|
||||
" { \"mode2\", []() { return 2; } },\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void block() {
|
||||
check("void f() {\n"
|
||||
" ({ do_something(); 0; });\n"
|
||||
|
|
Loading…
Reference in New Issue