Fixed #10271 (AST; Token::astOperand2() cyclic dependency in static_assert)

This commit is contained in:
Daniel Marjamäki 2021-05-07 13:19:28 +02:00
parent c9a9b56e0e
commit be95e2bf21
2 changed files with 3 additions and 5 deletions

View File

@ -477,7 +477,6 @@ static Token * skipDecl(Token *tok)
{
if (!Token::Match(tok->previous(), "( %name%"))
return tok;
Token *vartok = tok;
while (Token::Match(vartok, "%name%|*|&|::|<")) {
if (vartok->str() == "<") {
@ -487,7 +486,7 @@ static Token * skipDecl(Token *tok)
return tok;
} else if (Token::Match(vartok, "%var% [:=(]")) {
return vartok;
} else if (Token::simpleMatch(vartok, "decltype (")) {
} else if (Token::simpleMatch(vartok, "decltype (") && !Token::Match(tok->linkAt(1), ") [,)]")) {
return vartok->linkAt(1)->next();
}
vartok = vartok->next();

View File

@ -5822,9 +5822,6 @@ private:
ASSERT_EQUALS("decltypex({", testAst("decltype(x){};"));
ASSERT_EQUALS("decltypexy+(yx+(", testAst("decltype(x+y)(y+x);"));
ASSERT_EQUALS("decltypexy+(yx+{", testAst("decltype(x+y){y+x};"));
// Check that decltype(x){} doesn't break AST creation for subsequent tokens.
ASSERT_EQUALS("decltypex({01:?", testAst("decltype(x){} ? 0 : 1;"));
}
void astbrackets() { // []
@ -5851,6 +5848,8 @@ private:
// create ast for decltype
ASSERT_EQUALS("decltypex( var1=", testAst("decltype(x) var = 1;"));
ASSERT_EQUALS("a1bdecltypet((>2,(", testAst("a(1 > b(decltype(t)), 2);")); // #10271
ASSERT_EQUALS("decltypex({01:?", testAst("decltype(x){} ? 0 : 1;"));
}
void astunaryop() { // unary operators