Skip to content

Commit

Permalink
Parser: allow calling function via statement expression
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsan901998 authored and Vexu committed May 19, 2024
1 parent d8b689d commit 00273a1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/aro/Parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -6702,7 +6702,7 @@ fn removeUnusedWarningForTok(p: *Parser, last_expr_tok: TokenIndex) void {
}

/// castExpr
/// : '(' compoundStmt ')'
/// : '(' compoundStmt ')' suffixExpr*
/// | '(' typeName ')' castExpr
/// | '(' typeName ')' '{' initializerItems '}'
/// | __builtin_choose_expr '(' integerConstExpr ',' assignExpr ',' assignExpr ')'
Expand All @@ -6729,6 +6729,11 @@ fn castExpr(p: *Parser) Error!Result {
};
try p.expectClosing(l_paren, .r_paren);
try res.un(p, .stmt_expr);
while (true) {
const suffix = try p.suffixExpr(res);
if (suffix.empty(p)) break;
res = suffix;
}
return res;
}
const ty = (try p.typeName()) orelse {
Expand Down
1 change: 1 addition & 0 deletions test/cases/statement expressions.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ void foo(void) {
z;
});
z++;
({foo;})();
}

void self_referential_initializer(void) {
Expand Down

0 comments on commit 00273a1

Please sign in to comment.