Fixed parsing of C++11 initializatation in initializer list (#3957)
This commit is contained in:
parent
37d9d6fd7e
commit
68e19b33ff
|
@ -1134,8 +1134,11 @@ void SymbolDatabase::addNewFunction(Scope **scope, const Token **tok)
|
||||||
Scope *new_scope = &scopeList.back();
|
Scope *new_scope = &scopeList.back();
|
||||||
|
|
||||||
// skip to start of function
|
// skip to start of function
|
||||||
while (tok1 && tok1->str() != "{")
|
while (tok1 && tok1->str() != "{") {
|
||||||
|
if (tok1->str() == "(")
|
||||||
|
tok1 = tok1->link();
|
||||||
tok1 = tok1->next();
|
tok1 = tok1->next();
|
||||||
|
}
|
||||||
|
|
||||||
if (tok1) {
|
if (tok1) {
|
||||||
new_scope->classStart = tok1;
|
new_scope->classStart = tok1;
|
||||||
|
|
|
@ -103,6 +103,7 @@ private:
|
||||||
|
|
||||||
TEST_CASE(parseFunctionCorrect);
|
TEST_CASE(parseFunctionCorrect);
|
||||||
TEST_CASE(parseFunctionDeclarationCorrect);
|
TEST_CASE(parseFunctionDeclarationCorrect);
|
||||||
|
TEST_CASE(Cpp11InitInInitList);
|
||||||
|
|
||||||
TEST_CASE(hasGlobalVariables1);
|
TEST_CASE(hasGlobalVariables1);
|
||||||
TEST_CASE(hasGlobalVariables2);
|
TEST_CASE(hasGlobalVariables2);
|
||||||
|
@ -703,6 +704,15 @@ private:
|
||||||
ASSERT_EQUALS(3, db->findScopeByName("func")->classStart->linenr());
|
ASSERT_EQUALS(3, db->findScopeByName("func")->classStart->linenr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Cpp11InitInInitList() {
|
||||||
|
GET_SYMBOL_DB("class Foo {\n"
|
||||||
|
" std::vector<std::string> bar;\n"
|
||||||
|
" Foo() : bar({\"a\", \"b\"})\n"
|
||||||
|
" {}\n"
|
||||||
|
"};");
|
||||||
|
ASSERT_EQUALS(4, db->scopeList.front().nestedList.front()->nestedList.front()->classStart->linenr());
|
||||||
|
}
|
||||||
|
|
||||||
void hasGlobalVariables1() {
|
void hasGlobalVariables1() {
|
||||||
GET_SYMBOL_DB("int i;\n")
|
GET_SYMBOL_DB("int i;\n")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue