Fix 10739: internalAstError with decltype (#3723)

This commit is contained in:
Paul Fultz II 2022-01-20 14:36:48 -06:00 committed by GitHub
parent ebd1fbbfd8
commit 57b50e4b00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -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%|(")) {

View File

@ -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.(<i++;;( asize.(", testAst("for (decltype(a.size()) i = 0; i < a.size(); ++i);"));
ASSERT_EQUALS("foria:( asize.(", testAst("for(decltype(a.size()) i:a);"));
// for with initializer (c++20)
ASSERT_EQUALS("forab=ca:;(", testAst("for(a=b;int c:a)"));