AST: better handling of '(struct X){...}'

This commit is contained in:
Daniel Marjamäki 2017-04-06 21:28:13 +02:00
parent 70a7915173
commit 392a06a44b
2 changed files with 4 additions and 0 deletions

View File

@ -1008,6 +1008,9 @@ static void createAstAtTokenInner(Token * const tok1, const Token *endToken, boo
if (tok->str() == "{") {
if (Token::simpleMatch(tok->previous(), "( {"))
;
// struct assignment
else if (Token::simpleMatch(tok->previous(), ") {") && Token::simpleMatch(tok->linkAt(-1), "( struct"))
;
// Lambda function
else if (Token::simpleMatch(tok->astParent(), "(") &&
Token::simpleMatch(tok->astParent()->astParent(), "[") &&

View File

@ -8066,6 +8066,7 @@ private:
ASSERT_EQUALS("ab2[a0=b0=,{a0=b0=,{,{=", testAst("struct AB ab[2] = { { .a=0, .b=0 }, { .a=0, .b=0 } };"));
ASSERT_EQUALS("tset{=", testAst("struct cgroup_taskset tset = {};"));
ASSERT_EQUALS("s1a&,{2b&,{,{=", testAst("s = { {1, &a}, {2, &b} };"));
TODO_ASSERT_EQUALS("xatoistr({(=", "x{(= atoistr(", testAst("x = (struct X){atoi(str)};"));
// template parentheses: <>
ASSERT_EQUALS("stdfabs::m_similarity(numeric_limitsepsilon::(<=return", testAst("return std::fabs(m_similarity) <= numeric_limits<double>::epsilon();")); // #6195