Skip to content

Commit 9329772

Browse files
Fix internalASTError with decltype (refs #11378) (#5553)
1 parent dde956b commit 9329772

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

lib/tokenlist.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,8 @@ static void compileTerm(Token *&tok, AST_state& state)
762762
tok = tok->linkAt(1);
763763
else if (Token::Match(tok, "%name% ...") || (state.op.size() == 1 && state.depth == 0 && Token::Match(tok->tokAt(-3), "!!& ) ( %name% ) =")))
764764
tok = tok->next();
765+
else if (Token::simpleMatch(tok, "decltype (") && Token::simpleMatch(tok->linkAt(1), ") ::"))
766+
tok = tok->linkAt(1);
765767
tok = tok->next();
766768
if (Token::Match(tok, "%str%")) {
767769
while (Token::Match(tok, "%name%|%str%"))
@@ -836,7 +838,8 @@ static void compileScope(Token *&tok, AST_state& state)
836838
if (Token::Match(lastOp, ":: %name%"))
837839
lastOp = lastOp->next();
838840
if (Token::Match(lastOp, "%name%") &&
839-
(lastOp->next() == tok || (Token::Match(lastOp, "%name% <") && lastOp->linkAt(1) && tok == lastOp->linkAt(1)->next())))
841+
(lastOp->next() == tok ||
842+
(Token::Match(lastOp, "%name% <|(") && lastOp->linkAt(1) && tok == lastOp->linkAt(1)->next())))
840843
compileBinOp(tok, state, compileTerm);
841844
else
842845
compileUnaryOp(tok, state, compileTerm);

test/testtokenize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6073,7 +6073,7 @@ class TestTokenizer : public TestFixture {
60736073
// C++17: if (expr1; expr2)
60746074
ASSERT_EQUALS("ifx3=y;(", testAst("if (int x=3; y)"));
60756075

6076-
6076+
ASSERT_EQUALS("xstdstring::decltypea::{=", testAst("auto x = std::string{ decltype(s)::a };"));
60776077
}
60786078

60796079
void astexpr2() { // limit for large expressions

0 commit comments

Comments
 (0)