Fixed #5493 (False positive: Found a statement that begins with numeric constant / string constant - in the presence of initialization list.)
This commit is contained in:
parent
8550289722
commit
7dbfd67da3
|
@ -2166,8 +2166,8 @@ void CheckOther::checkIncompleteStatement()
|
|||
else if (Token::simpleMatch(tok, "= {"))
|
||||
tok = tok->next()->link();
|
||||
|
||||
// C++11 struct/array initialization in initializer list
|
||||
else if (tok->str() == "{" && Token::Match(tok->tokAt(-2), ",|: %var%") && Token::Match(tok->link(), "} [,{]"))
|
||||
// C++11 struct/array/etc initialization in initializer list
|
||||
else if (Token::Match(tok->previous(), "%var% {") && !Token::findsimplematch(tok,";",tok->link()))
|
||||
tok = tok->link();
|
||||
|
||||
// C++11 vector initialization / return { .. }
|
||||
|
|
|
@ -68,6 +68,7 @@ private:
|
|||
TEST_CASE(returnstruct);
|
||||
TEST_CASE(cast); // #3009 : (struct Foo *)123.a = 1;
|
||||
TEST_CASE(increment); // #3251 : FP for increment
|
||||
TEST_CASE(cpp11init); // #5493 : int i{1};
|
||||
}
|
||||
|
||||
void test1() {
|
||||
|
@ -220,6 +221,13 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void cpp11init() {
|
||||
check("void f() {\n"
|
||||
" int x{1};\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST(TestIncompleteStatement)
|
||||
|
|
Loading…
Reference in New Issue