Token::typeDecl: Fix endless recursion for code:

void f()
{
  auto val = val;
}

I did not manage to pinpoint a good location to put a unit test. However this will be tested when daca@home runs the package gcc-avr.
This commit is contained in:
Daniel Marjamäki 2021-08-26 19:03:35 +02:00
parent 1cd9d0479d
commit f31fbba54a
1 changed files with 1 additions and 1 deletions

View File

@ -2335,7 +2335,7 @@ std::pair<const Token*, const Token*> Token::typeDecl(const Token * tok)
const Token * tok2 = var->declEndToken();
if (Token::Match(tok2, "; %varid% =", var->declarationId()))
tok2 = tok2->tokAt(2);
if (Token::simpleMatch(tok2, "=") && Token::Match(tok2->astOperand2(), "!!=")) {
if (Token::simpleMatch(tok2, "=") && Token::Match(tok2->astOperand2(), "!!=") && tok != tok2->astOperand2()) {
std::pair<const Token*, const Token*> r = typeDecl(tok2->astOperand2());
if (r.first)
return r;