Revert "AST: Adjust AST for variable declaration 'char var[] = str;'"
This reverts commit 376860f796
.
This commit is contained in:
parent
4094274723
commit
26e6eed189
|
@ -1553,22 +1553,8 @@ static Token * createAstAtToken(Token *tok, bool cpp)
|
|||
typecount++;
|
||||
typetok = typetok->next();
|
||||
}
|
||||
if (Token::Match(typetok, "%var% =|[") && typetok->varId()) {
|
||||
Token *tok2 = typetok->next();
|
||||
while (Token::simpleMatch(tok2, "["))
|
||||
tok2 = tok2->link()->next();
|
||||
if (Token::simpleMatch(tok2, "=")) {
|
||||
AST_state state(cpp);
|
||||
state.op.push(typetok);
|
||||
Token * const start = tok2;
|
||||
compileBinOp(tok2, state, compileAssignTernary);
|
||||
if (tok2 == start || !tok2)
|
||||
return start;
|
||||
createAstAtTokenInner(start->next(), tok2, cpp);
|
||||
return tok2;
|
||||
} else if (Token::simpleMatch(tok2, ";"))
|
||||
return tok;
|
||||
}
|
||||
if (Token::Match(typetok, "%var% =") && typetok->varId())
|
||||
tok = typetok;
|
||||
|
||||
// Do not create AST for function declaration
|
||||
if (typetok &&
|
||||
|
|
|
@ -7857,7 +7857,7 @@ private:
|
|||
|
||||
void astvardecl() {
|
||||
// Variable declaration
|
||||
ASSERT_EQUALS("var\"\"=", testAst("char var[1]=\"\";"));
|
||||
ASSERT_EQUALS("a1[\"\"=", testAst("char a[1]=\"\";"));
|
||||
ASSERT_EQUALS("charp*(3[char5[3[new=", testAst("char (*p)[3] = new char[5][3];"));
|
||||
ASSERT_EQUALS("varp=", testAst("const int *var = p;"));
|
||||
|
||||
|
|
Loading…
Reference in New Issue