Fixed #10442 (AST: wrong ast of ({}) in struct initialization) (#5135)

This commit is contained in:
Daniel Marjamäki 2023-06-09 22:31:14 +02:00 committed by GitHub
parent 6ea88c2758
commit 22e67d3534
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View File

@ -971,6 +971,10 @@ static void compilePrecedence2(Token *&tok, AST_state& state)
else
compileUnaryOp(tok, state, compileExpression);
tok = tok2->link()->next();
} else if (Token::simpleMatch(tok, "( {") && Token::simpleMatch(tok->linkAt(1)->previous(), "; } )") && !Token::Match(tok->previous(), "%name% (")) {
state.op.push(tok->next());
tok = tok->link()->next();
continue;
} else if (tok->str() == "(" && (!iscast(tok, state.cpp) || Token::Match(tok->previous(), "if|while|for|switch|catch"))) {
Token* tok2 = tok;
tok = tok->next();

View File

@ -6266,6 +6266,7 @@ private:
ASSERT_EQUALS("fori10=i{;;( i--", testAst("for (i=10;i;({i--;}) ) {}"));
ASSERT_EQUALS("c{1{,{2.3f{,(",
testAst("c({{}, {1}}, {2.3f});"));
ASSERT_EQUALS("x{{= e0= assert0(", testAst("x = {({ int e = 0; assert(0); e; })};"));
// function pointer
TODO_ASSERT_EQUALS("todo", "va_argapvoid((,(*0=", testAst("*va_arg(ap, void(**) ()) = 0;"));