Commit d321a4b765
Changed files (2)
test
src/translate_c.zig
@@ -1682,6 +1682,9 @@ fn transDeclStmtOne(
.Enum => {
try transEnumDecl(c, scope, @ptrCast(*const clang.EnumDecl, decl));
},
+ .Function => {
+ try visitFnDecl(c, @ptrCast(*const clang.FunctionDecl, decl));
+ },
else => |kind| return fail(
c,
error.UnsupportedTranslation,
test/translate_c.zig
@@ -3529,4 +3529,16 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\warning: unable to translate function, demoted to extern
\\pub extern fn initialize() void;
});
+
+ cases.add("Function prototype declared within function",
+ \\int foo(void) {
+ \\ extern int bar(int, int);
+ \\ return bar(1, 2);
+ \\}
+ , &[_][]const u8{
+ \\pub extern fn bar(c_int, c_int) c_int;
+ \\pub export fn foo() c_int {
+ \\ return bar(@as(c_int, 1), @as(c_int, 2));
+ \\}
+ });
}