mirror of
https://github.com/ziglang/zig.git
synced 2026-02-15 05:48:31 +00:00
translate-c supports returning void
This commit is contained in:
parent
cd36baf530
commit
18eb3c5f90
@ -937,8 +937,7 @@ static AstNode *trans_compound_stmt(Context *c, AstNode *parent, CompoundStmt *s
|
||||
static AstNode *trans_return_stmt(Context *c, AstNode *block, ReturnStmt *stmt) {
|
||||
Expr *value_expr = stmt->getRetValue();
|
||||
if (value_expr == nullptr) {
|
||||
emit_warning(c, stmt->getLocStart(), "TODO handle C return void");
|
||||
return nullptr;
|
||||
return trans_create_node(c, NodeTypeReturnExpr);
|
||||
} else {
|
||||
AstNode *return_node = trans_create_node(c, NodeTypeReturnExpr);
|
||||
return_node->data.return_expr.expr = trans_expr(c, true, block, value_expr, TransRValue);
|
||||
|
||||
@ -939,6 +939,16 @@ pub fn addCases(cases: &tests.TranslateCContext) {
|
||||
\\ return c"bar";
|
||||
\\}
|
||||
);
|
||||
|
||||
cases.add("return void",
|
||||
\\void foo(void) {
|
||||
\\ return;
|
||||
\\}
|
||||
,
|
||||
\\pub fn foo() {
|
||||
\\ return;
|
||||
\\}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user