Fix internalASTError with decltype (regression, refs #11378) (#5564)

This commit is contained in:
chrchr-github 2023-10-18 12:17:20 +02:00 committed by GitHub
parent bfe19af6b2
commit b60b374f9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -763,8 +763,6 @@ static void compileTerm(Token *&tok, AST_state& state)
tok = tok->linkAt(1);
else if (Token::Match(tok, "%name% ...") || (state.op.size() == 1 && state.depth == 0 && Token::Match(tok->tokAt(-3), "!!& ) ( %name% ) =")))
tok = tok->next();
else if (Token::simpleMatch(tok, "decltype (") && Token::simpleMatch(tok->linkAt(1), ") ::"))
tok = tok->linkAt(1);
tok = tok->next();
if (Token::Match(tok, "%str%")) {
while (Token::Match(tok, "%name%|%str%"))
@ -839,8 +837,7 @@ static void compileScope(Token *&tok, AST_state& state)
if (Token::Match(lastOp, ":: %name%"))
lastOp = lastOp->next();
if (Token::Match(lastOp, "%name%") &&
(lastOp->next() == tok ||
(Token::Match(lastOp, "%name% <|(") && lastOp->linkAt(1) && tok == lastOp->linkAt(1)->next())))
(lastOp->next() == tok || (Token::Match(lastOp, "%name% <") && lastOp->linkAt(1) && tok == lastOp->linkAt(1)->next())))
compileBinOp(tok, state, compileTerm);
else
compileUnaryOp(tok, state, compileTerm);
@ -1003,6 +1000,8 @@ static void compilePrecedence2(Token *&tok, AST_state& state)
compileUnaryOp(tok, state, nullptr);
}
tok = tok->link()->next();
if (Token::simpleMatch(tok, "::"))
compileBinOp(tok, state, compileTerm);
} else if (iscast(tok, state.cpp) && Token::simpleMatch(tok->link(), ") {") && Token::simpleMatch(tok->link()->linkAt(1), "} [")) {
Token *cast = tok;
tok = tok->link()->next();

View File

@ -6073,7 +6073,8 @@ private:
// C++17: if (expr1; expr2)
ASSERT_EQUALS("ifx3=y;(", testAst("if (int x=3; y)"));
ASSERT_EQUALS("xstdstring::decltypea::{=", testAst("auto x = std::string{ decltype(s)::a };"));
ASSERT_EQUALS("xstdstring::decltypes(a::{=", testAst("auto x = std::string{ decltype(s)::a };"));
ASSERT_EQUALS("if0decltypest.(X::>(", testAst("if (0 > decltype(s.t)::X) {}"));
}
void astexpr2() { // limit for large expressions