mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
translate-c: Translate FnDecl's that appear within functions
This commit is contained in:
parent
e8236551ab
commit
d321a4b765
@ -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,
|
||||
|
||||
@ -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));
|
||||
\\}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user