Skip to content

Commit

Permalink
Fix internalASTError with decltype (refs #11378) (danmar#5553)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrchr-github authored Oct 15, 2023
1 parent dde956b commit 9329772
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/tokenlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,8 @@ 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%"))
Expand Down Expand Up @@ -836,7 +838,8 @@ 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);
Expand Down
2 changes: 1 addition & 1 deletion test/testtokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6073,7 +6073,7 @@ class TestTokenizer : public TestFixture {
// 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 };"));
}

void astexpr2() { // limit for large expressions
Expand Down

0 comments on commit 9329772

Please sign in to comment.