Another fix for 10739: internalAstError with decltype (#3738)

* Another fix for 10739: internalAstError with decltype

* Format
This commit is contained in:
Paul Fultz II 2022-01-22 00:22:57 -06:00 committed by GitHub
parent b23ca879ed
commit 8b1ed9cbe1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -784,7 +784,13 @@ static void compileTerm(Token *&tok, AST_state& state)
tok = tok->tokAt(2);
}
} else if (!state.cpp || !Token::Match(tok, "new|delete %name%|*|&|::|(|[")) {
Token* tok2 = tok;
tok = skipDecl(tok);
if (Token::simpleMatch(tok2, "decltype (")) {
Token* tok3 = tok2->next();
AST_state state1(state.cpp);
compileExpression(tok3, state1);
}
bool repeat = true;
while (repeat) {
repeat = false;

View File

@ -6885,6 +6885,15 @@ private:
ASSERT_NO_THROW(tokenizeAndStringify("void a() {\n"
" [b = [] { ; }] {};\n"
"}\n"));
// #10739
ASSERT_NO_THROW(tokenizeAndStringify("struct a {\n"
" std::vector<int> b;\n"
"};\n"
"void c() {\n"
" a bar;\n"
" (decltype(bar.b)::value_type){};\n"
"}\n"));
}
void checkIfCppCast() {
ASSERT_NO_THROW(tokenizeAndStringify("struct a {\n"