From 57b50e4b007b6e89456a9b7f40dc4aef21b4e86f Mon Sep 17 00:00:00 2001 From: Paul Fultz II Date: Thu, 20 Jan 2022 14:36:48 -0600 Subject: [PATCH] Fix 10739: internalAstError with decltype (#3723) --- lib/tokenlist.cpp | 5 +++++ test/testtokenize.cpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index f6430abdd..4cee3f838 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -1424,6 +1424,11 @@ static Token * createAstAtToken(Token *tok, bool cpp) } Token *tok2 = skipDecl(tok->tokAt(2)); + if (Token::simpleMatch(tok->tokAt(2), "decltype (")) { + Token* tok3 = tok->tokAt(4); + AST_state state1(cpp); + compileExpression(tok3, state1); + } Token *init1 = nullptr; Token * const endPar = tok->next()->link(); if (tok2 == tok->tokAt(2) && Token::Match(tok2, "%op%|(")) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index bacc6e553..90638b15f 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -5906,6 +5906,8 @@ private: ASSERT_EQUALS("for(tmpNULL!=tmptmpnext.=;;( tmpa=", testAst("for ( ({ tmp = a; }) ; tmp != NULL; tmp = tmp->next ) {}")); ASSERT_EQUALS("forx0=x;;(", testAst("for (int x=0; x;);")); ASSERT_EQUALS("forae*bc.({:(", testAst("for (a *e : {b->c()});")); + ASSERT_EQUALS("fori0=iasize.(