Commit 18eb3c5f90
Changed files (2)
test
src/translate_c.cpp
@@ -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);
test/translate_c.zig
@@ -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;
+ \\}
+ );
}