Fixed #7054 (AST: handle C++ initialization with {} better)
This commit is contained in:
parent
399f8492d6
commit
c88297c971
|
@ -527,6 +527,16 @@ static void compileTerm(Token *&tok, AST_state& state)
|
||||||
} else if (Token::Match(tok, "sizeof !!(")) {
|
} else if (Token::Match(tok, "sizeof !!(")) {
|
||||||
compileUnaryOp(tok, state, compileExpression);
|
compileUnaryOp(tok, state, compileExpression);
|
||||||
state.op.pop();
|
state.op.pop();
|
||||||
|
} else if (state.cpp && Token::Match(tok,"%name% {")) {
|
||||||
|
state.op.push(tok);
|
||||||
|
tok = tok->next();
|
||||||
|
|
||||||
|
if (Token::simpleMatch(tok, "{ }"))
|
||||||
|
compileUnaryOp(tok, state, compileExpression);
|
||||||
|
else
|
||||||
|
compileBinOp(tok, state, compileExpression);
|
||||||
|
if (Token::Match(tok, "}"))
|
||||||
|
tok = tok->next();
|
||||||
} else if (!state.cpp || !Token::Match(tok, "new|delete %name%|*|&|::|(|[")) {
|
} else if (!state.cpp || !Token::Match(tok, "new|delete %name%|*|&|::|(|[")) {
|
||||||
while (tok->next() && tok->next()->isName())
|
while (tok->next() && tok->next()->isName())
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
|
|
@ -8027,7 +8027,7 @@ private:
|
||||||
ASSERT_EQUALS("fabc,de,:?=", testAst("f = (a ? (b, c) : (d, e));"));
|
ASSERT_EQUALS("fabc,de,:?=", testAst("f = (a ? (b, c) : (d, e));"));
|
||||||
ASSERT_EQUALS("fabc,de,:?=", testAst("f = (a ? b, c : (d, e));"));
|
ASSERT_EQUALS("fabc,de,:?=", testAst("f = (a ? b, c : (d, e));"));
|
||||||
ASSERT_EQUALS("ab35,4:?foo(:?return", testAst("return (a ? b ? (3,5) : 4 : foo());"));
|
ASSERT_EQUALS("ab35,4:?foo(:?return", testAst("return (a ? b ? (3,5) : 4 : foo());"));
|
||||||
ASSERT_EQUALS("check(result_typeinvalid:?return", testAst("return check() ? result_type {0, 0} : invalid;"));
|
ASSERT_EQUALS("check(result_type00,{invalid:?return", testAst("return check() ? result_type {0, 0} : invalid;"));
|
||||||
|
|
||||||
ASSERT_EQUALS("a\"\"=", testAst("a=\"\""));
|
ASSERT_EQUALS("a\"\"=", testAst("a=\"\""));
|
||||||
ASSERT_EQUALS("a\'\'=", testAst("a=\'\'"));
|
ASSERT_EQUALS("a\'\'=", testAst("a=\'\'"));
|
||||||
|
@ -8065,7 +8065,7 @@ private:
|
||||||
|
|
||||||
ASSERT_EQUALS("abc.1:?1+bd.1:?+=", testAst("a =(b.c ? : 1) + 1 + (b.d ? : 1);"));
|
ASSERT_EQUALS("abc.1:?1+bd.1:?+=", testAst("a =(b.c ? : 1) + 1 + (b.d ? : 1);"));
|
||||||
|
|
||||||
ASSERT_EQUALS("catch.(", testAst("try {} catch (...) {}"));
|
ASSERT_EQUALS("try{ catch.(", testAst("try {} catch (...) {}"));
|
||||||
|
|
||||||
ASSERT_EQUALS("FooBar(", testAst("void Foo(Bar&);"));
|
ASSERT_EQUALS("FooBar(", testAst("void Foo(Bar&);"));
|
||||||
ASSERT_EQUALS("FooBar(", testAst("void Foo(Bar& &);")); // Rvalue reference - simplified from && to & & by real tokenizer
|
ASSERT_EQUALS("FooBar(", testAst("void Foo(Bar& &);")); // Rvalue reference - simplified from && to & & by real tokenizer
|
||||||
|
@ -8171,8 +8171,14 @@ private:
|
||||||
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} };"));
|
||||||
|
|
||||||
// template paratheses: <>
|
// 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
|
||||||
|
|
||||||
|
// C++ initializer
|
||||||
|
ASSERT_EQUALS("Class{", testAst("Class{};"));
|
||||||
|
ASSERT_EQUALS("Class12,{", testAst("Class{1,2};"));
|
||||||
|
ASSERT_EQUALS("abc{d:?=", testAst("a=b?c{}:d;"));
|
||||||
|
ASSERT_EQUALS("abc12,{d:?=", testAst("a=b?c{1,2}:d;"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void astbrackets() { // []
|
void astbrackets() { // []
|
||||||
|
|
Loading…
Reference in New Issue