AST: better handling of '(struct X){...}'
This commit is contained in:
parent
70a7915173
commit
392a06a44b
|
@ -1008,6 +1008,9 @@ static void createAstAtTokenInner(Token * const tok1, const Token *endToken, boo
|
||||||
if (tok->str() == "{") {
|
if (tok->str() == "{") {
|
||||||
if (Token::simpleMatch(tok->previous(), "( {"))
|
if (Token::simpleMatch(tok->previous(), "( {"))
|
||||||
;
|
;
|
||||||
|
// struct assignment
|
||||||
|
else if (Token::simpleMatch(tok->previous(), ") {") && Token::simpleMatch(tok->linkAt(-1), "( struct"))
|
||||||
|
;
|
||||||
// Lambda function
|
// Lambda function
|
||||||
else if (Token::simpleMatch(tok->astParent(), "(") &&
|
else if (Token::simpleMatch(tok->astParent(), "(") &&
|
||||||
Token::simpleMatch(tok->astParent()->astParent(), "[") &&
|
Token::simpleMatch(tok->astParent()->astParent(), "[") &&
|
||||||
|
|
|
@ -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("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("tset{=", testAst("struct cgroup_taskset tset = {};"));
|
||||||
ASSERT_EQUALS("s1a&,{2b&,{,{=", testAst("s = { {1, &a}, {2, &b} };"));
|
ASSERT_EQUALS("s1a&,{2b&,{,{=", testAst("s = { {1, &a}, {2, &b} };"));
|
||||||
|
TODO_ASSERT_EQUALS("xatoistr({(=", "x{(= atoistr(", testAst("x = (struct X){atoi(str)};"));
|
||||||
|
|
||||||
// template parentheses: <>
|
// template parentheses: <>
|
||||||
ASSERT_EQUALS("stdfabs::m_similarity(numeric_limitsepsilon::(<=return", testAst("return std::fabs(m_similarity) <= numeric_limits<double>::epsilon();")); // #6195
|
ASSERT_EQUALS("stdfabs::m_similarity(numeric_limitsepsilon::(<=return", testAst("return std::fabs(m_similarity) <= numeric_limits<double>::epsilon();")); // #6195
|
||||||
|
|
Loading…
Reference in New Issue