AST; Improved ast for variable declaration with assignment

This commit is contained in:
Daniel Marjamäki 2020-06-22 08:34:08 +02:00
parent 44f87750e0
commit 9b5986505e
2 changed files with 4 additions and 8 deletions

View File

@ -1487,16 +1487,10 @@ static Token * createAstAtToken(Token *tok, bool cpp)
return tok->linkAt(1);
if (Token::Match(tok, "%type% %name%|*|&|::") && tok->str() != "return") {
bool decl = false;
Token *typetok = tok;
while (Token::Match(typetok, "%type%|::|*|&")) {
if (typetok->isStandardType() || Token::Match(typetok, "struct|const|static"))
decl = true;
while (Token::Match(typetok, "%type%|::|*|&"))
typetok = typetok->next();
}
if (!typetok)
return nullptr;
if (decl && Token::Match(typetok->previous(), "[*&] %var% ="))
if (Token::Match(typetok, "%var% =") && typetok->varId())
tok = typetok;
}

View File

@ -7781,6 +7781,8 @@ private:
"Ref<X> r;\n"
"int x(0);";
ASSERT_EQUALS("unoRef:: x0(", testAst(code1));
ASSERT_EQUALS("vary=", testAst("std::string var = y;"));
}
void astunaryop() { // unary operators