Fixed #9782 (Segmentation fault due to broken AST)
This commit is contained in:
parent
ba84303501
commit
2748201d73
|
@ -788,11 +788,17 @@ static void compileTerm(Token *&tok, AST_state& state)
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
if (tok->str() == "<")
|
if (tok->str() == "<")
|
||||||
tok = tok->link()->next();
|
tok = tok->link()->next();
|
||||||
|
|
||||||
if (Token::Match(tok, "{ . %name% =|{")) {
|
if (Token::Match(tok, "{ . %name% =|{")) {
|
||||||
const int inArrayAssignment = state.inArrayAssignment;
|
const int inArrayAssignment = state.inArrayAssignment;
|
||||||
state.inArrayAssignment = 1;
|
state.inArrayAssignment = 1;
|
||||||
compileBinOp(tok, state, compileExpression);
|
compileBinOp(tok, state, compileExpression);
|
||||||
state.inArrayAssignment = inArrayAssignment;
|
state.inArrayAssignment = inArrayAssignment;
|
||||||
|
} else if (Token::simpleMatch(tok, "{ }")) {
|
||||||
|
tok->astOperand1(state.op.top());
|
||||||
|
state.op.pop();
|
||||||
|
state.op.push(tok);
|
||||||
|
tok = tok->tokAt(2);
|
||||||
}
|
}
|
||||||
} else if (!state.cpp || !Token::Match(tok, "new|delete %name%|*|&|::|(|[")) {
|
} else if (!state.cpp || !Token::Match(tok, "new|delete %name%|*|&|::|(|[")) {
|
||||||
tok = skipDecl(tok);
|
tok = skipDecl(tok);
|
||||||
|
@ -828,9 +834,14 @@ static void compileTerm(Token *&tok, AST_state& state)
|
||||||
if (Token::simpleMatch(tok->link(),"} [")) {
|
if (Token::simpleMatch(tok->link(),"} [")) {
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
} else if (state.cpp && iscpp11init(tok)) {
|
} else if (state.cpp && iscpp11init(tok)) {
|
||||||
if (state.op.empty() || Token::Match(tok->previous(), "[{,]") || Token::Match(tok->tokAt(-2), "%name% ("))
|
if (state.op.empty() || Token::Match(tok->previous(), "[{,]") || Token::Match(tok->tokAt(-2), "%name% (")) {
|
||||||
compileUnaryOp(tok, state, compileExpression);
|
if (Token::Match(tok, "{ !!}"))
|
||||||
else
|
compileUnaryOp(tok, state, compileExpression);
|
||||||
|
else {
|
||||||
|
state.op.push(tok);
|
||||||
|
tok = tok->tokAt(2);
|
||||||
|
}
|
||||||
|
} else
|
||||||
compileBinOp(tok, state, compileExpression);
|
compileBinOp(tok, state, compileExpression);
|
||||||
if (Token::Match(tok, "} ,|:"))
|
if (Token::Match(tok, "} ,|:"))
|
||||||
tok = tok->next();
|
tok = tok->next();
|
||||||
|
|
|
@ -7835,6 +7835,7 @@ private:
|
||||||
ASSERT_EQUALS("a{{return", testAst("return{{a}};"));
|
ASSERT_EQUALS("a{{return", testAst("return{{a}};"));
|
||||||
ASSERT_EQUALS("a{b{,{return", testAst("return{{a},{b}};"));
|
ASSERT_EQUALS("a{b{,{return", testAst("return{{a},{b}};"));
|
||||||
ASSERT_EQUALS("stdvector::", testAst("std::vector<std::vector<int>>{{},{}}"));
|
ASSERT_EQUALS("stdvector::", testAst("std::vector<std::vector<int>>{{},{}}"));
|
||||||
|
ASSERT_EQUALS("abR{{,P(,((", testAst("a(b(R{},{},P()));"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void astbrackets() { // []
|
void astbrackets() { // []
|
||||||
|
|
Loading…
Reference in New Issue