Fixed #6214 (non-static member initializer causes false positive (function call; initializer))
This commit is contained in:
parent
aac9e66147
commit
11867e3210
|
@ -1201,8 +1201,11 @@ void Variable::evaluate()
|
|||
}
|
||||
// check for C++11 member initialization
|
||||
if (_scope && _scope->isClassOrStruct()) {
|
||||
// type var = x or
|
||||
// type var = {x}
|
||||
// type var = x; gets simplified to: type var ; var = x ;
|
||||
if (Token::Match(_name, "%var% ; %var% = %any% ;") && _name->strAt(2) == _name->str())
|
||||
if ((Token::Match(_name, "%var% ; %var% = ") && _name->strAt(2) == _name->str()) ||
|
||||
Token::Match(_name, "%var% {"))
|
||||
setFlag(fHasDefault, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ private:
|
|||
TEST_CASE(simple8);
|
||||
TEST_CASE(simple9); // ticket #4574
|
||||
TEST_CASE(simple10); // ticket #4388
|
||||
TEST_CASE(simple11); // ticket #4536
|
||||
TEST_CASE(simple11); // ticket #4536, #6214
|
||||
TEST_CASE(simple12); // ticket #4620
|
||||
TEST_CASE(simple13); // #5498 - no constructor, c++11 assignments
|
||||
|
||||
|
@ -377,12 +377,14 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void simple11() { // ticket #4536
|
||||
void simple11() { // ticket #4536, #6214
|
||||
check("class Fred {\n"
|
||||
"public:\n"
|
||||
" Fred() {}\n"
|
||||
"private:\n"
|
||||
" int x = 0;\n"
|
||||
" int y = f();\n"
|
||||
" int z{0};\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue